Skip to content

Commit 92de394

Browse files
authored
Add diagham_command to only create the command string and add option wait to run (#5)
* Add `diagham_command` to only create the command string. Also add option `wait` to `execute_diagham_script` to control whether the process should be waited for. * format
1 parent 3acfc36 commit 92de394

2 files changed

Lines changed: 38 additions & 22 deletions

File tree

src/DiagHamInterface.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Interface to the DiagHam library.
44
module DiagHamInterface
55

66
export execute_diagham_script
7+
export diagham_command
78
export install_diagham
89

910
export read_matrix_from_txt
@@ -17,7 +18,7 @@ using Preferences
1718

1819
include("utility/backup.jl")
1920
include("utility/diagham_path.jl")
20-
include("utility/execute_script.jl")
21+
include("utility/diagham_script.jl")
2122
include("utility/diagham_install.jl")
2223
include("utility/fileending.jl")
2324
include("utility/numbers.jl")
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
"""
2-
execute_diagham_script(execute; kwargs...)
3-
4-
Run a DiagHam executable. Kwargs are converted to CLI flags (`_` → `-`).
5-
Single-char keys use `-k`, multi-char use `--key`. Boolean `true` adds flag, `false` omits.
6-
7-
The kwargs of `Cmd()` are supported.
2+
diagham_command(execute; kwargs...)
3+
Construct a command string for running a DiagHam executable with specified kwargs as CLI flags.
84
"""
9-
function execute_diagham_script(execute::AbstractString; kwargs...)
10-
return execute_diagham_script([execute]; kwargs...)
5+
function diagham_command(execute::AbstractString; kwargs...)
6+
return diagham_command([execute]; kwargs...)
117
end
12-
13-
function execute_diagham_script(
8+
function diagham_command(
149
execute::AbstractVector{<:AbstractString};
1510
diagham_path::AbstractString = get_diagham_path(),
16-
ignorestatus::Bool = false,
17-
detach::Bool = false,
18-
windows_verbatim::Bool = false,
19-
windows_hide::Bool = false,
20-
env = nothing,
21-
dir = "",
2211
kwargs...
2312
)
2413
warn_about_diagham_path()
25-
2614
ex_file = first(execute)
2715
execute[1] = joinpath(diagham_path, ex_file)
2816
execute = prod(execute)
@@ -31,10 +19,7 @@ function execute_diagham_script(
3119
for (k, v) in kwargs
3220
execute *= diagham_kwarg(k, v)
3321
end
34-
35-
execute = Cmd(split(execute, " "))
36-
cmd = Cmd(execute; ignorestatus = ignorestatus, detach = detach, windows_verbatim = windows_verbatim, windows_hide = windows_hide, env = env, dir = dir)
37-
return run(cmd)
22+
return execute
3823
end
3924

4025
function diagham_kwarg(key, value)
@@ -49,3 +34,33 @@ function diagham_kwarg(key, value)
4934
end
5035
return ""
5136
end
37+
38+
"""
39+
execute_diagham_script(execute; kwargs...)
40+
41+
Run a DiagHam executable. Kwargs are converted to CLI flags (`_` → `-`).
42+
Single-char keys use `-k`, multi-char use `--key`. Boolean `true` adds flag, `false` omits.
43+
44+
The kwargs of `Cmd()` and `run()` are supported.
45+
"""
46+
function execute_diagham_script(execute::AbstractString; kwargs...)
47+
return execute_diagham_script([execute]; kwargs...)
48+
end
49+
function execute_diagham_script(
50+
execute::AbstractVector{<:AbstractString};
51+
diagham_path::AbstractString = get_diagham_path(),
52+
ignorestatus::Bool = false,
53+
detach::Bool = false,
54+
windows_verbatim::Bool = false,
55+
windows_hide::Bool = false,
56+
env = nothing,
57+
dir = "",
58+
wait::Bool = true,
59+
cleanup::Bool = false,
60+
kwargs...
61+
)
62+
execute = diagham_command(execute; diagham_path, kwargs...)
63+
execute = Cmd(split(execute, " "))
64+
cmd = Cmd(execute; ignorestatus = ignorestatus, detach = detach, windows_verbatim = windows_verbatim, windows_hide = windows_hide, env = env, dir = dir)
65+
return run(cmd; wait = wait)
66+
end

0 commit comments

Comments
 (0)