2

Is there any better way to specify a "computed default value" of a command-line argument that depends on other arguments in ArgParse.jl than simply check and set after parsing?

Current straightforward "workaround" is like this:

s = ArgParse.ArgParseSettings()
ArgParse.@add_arg_table! s begin
    "--project_dir"
        default = pwd()
    "--sub_dir"
        default = "subproject1"
    "--data_dir"
        # by default default is nothing, I fill it in later
end
args = ArgParse.parse_args(ARGS, s)

# Filling in "data_dir"
if args["data_dir"] === nothing
    args["data_dir"] = joinpath(args["project_dir"], args["sub_dir"], "data")
end
Alex Chichigin
  • 121
  • 1
  • 4

0 Answers0