Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested options #119

Open
acdupont opened this issue Dec 4, 2022 · 0 comments
Open

Support nested options #119

acdupont opened this issue Dec 4, 2022 · 0 comments

Comments

@acdupont
Copy link

acdupont commented Dec 4, 2022

Would there be interest in some sort of "extended" option that has a similar api as a command, but is treated like an option? The use case I'm interested in is mapping a cli interface to a json configuration file.

A json file such as:

{
  "o1": "o1value",
  "o2": "o2value",
  "extended1": {
    "e1o1": "n1o1value"
  }
}

would have ArgParseSettings such as:

s = ArgParseSettings()

@add_arg_table! s begin
  "--o1"
    action = :store_arg
  "--o2"
    action = :store_arg
  "extended1"
    action = :extended_arg
end

@add_arg_table! s["extended1"] begin
  "e1p1"
    help = "e1p1 positional argument"
    action = :store_arg
  "--e1o1"
    action = :store_arg
end

and would look something like this on the cli:

myprog --o1 o1value extended1 e1p1value --e1o1 e1o1value --o2 o2value

and lastly would result in parsed args:

parsed_args =
 Dict{Symbol, Any} with 5 entries:
   :o1   => "o1value"
   :o2   => "o2value"
   :extended1  => Dict{Symbol, Any}(:e1p1=>"e1p1value", :e1o1=>e1o1value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant