-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Non-hierarchical subcommands / positional subcommands #1407
Comments
I know its been a while since you've posted on this, so sorry about this. I'm assuming that there are args specific to the input and output subcommands that you want specific ordering for and that is why you need to use subcommands rather than positional arguments with
Have an example? I've used argparse but not familiar with this functionality. I'm curious to see how other libraries handle this as this adds a certain level of complexity |
Forget to tag this as related to #2222. Maybe even a duplicate? |
I think they are slightly different. In #2222, the request is for the following to be equivalent $ cmd start stop
$ cmd staet && cmd stop While this would have
If we applied #2222's reasoning, this would run the |
btw if the main concern is the help output, the user can provide that directly. Maintaining that is annoying. #2913 and #2914 would allow custom dynamic help generation. For now, I'm leaning towards that being our suggested route forward as this seems fairly specialized with a degree of its own complications. If there are concerns about that, let us know! |
Rust Version
rustc 1.32.0 (9fda7c223 2019-01-16)
Affected Version of clap
2.32.0
Bug or Feature Request Summary
I would like to be able to create a set an argument parsers for an utility that takes a list of commands to specify a list of input formats (let's call them
IFs
) and the set of commands that specify the output formats (OFs
).Currently, in order to do that I would need to create a whole tree of subcommands independently for each
IF
and for eachOF
. It doesn't seem to be an issue, but the output of--help
would require to always specify at least one of theIFs
in order to see the outputs of duplicatedOFs
in each of theIFs
- that doesn't make for a user-friendly experience.I come from python where
argparse
module allows you to do that: instead of specifying subcommands on the root parser - they simply return an instance ofSubCommands
that allows you to then specify the subcommands for that specific positional subcommand group.Current Behaviour
Given
IFs
ofxml, csv, txt
andOFs
ofxml, csv, txt
, the only way to specify those as subcommands would be (showing the output of the--help
)IFs
help>> convert --help USAGE: convert [SUBCOMMAND] SUBCOMMANDS: xml desc_a csv desc_b txt desc_c
The going down to
OFs
:>> convert xml --help USAGE: convert xml [SUBCOMMAND] SUBCOMMANDS: xml desc_a csv desc_b txt desc_c
As is shown above, the output of every sub-sub-command would be the same regardless of what had been picked in the sub-command.
Expected Behavior Summary
>> convert --help USAGE: convert [INPUT] [OUTPUT] INPUT_SUBCOMMANDS: xml desc_a csv desc_b txt desc_c OUTPUT_SUBCOMMANDS: xml desc_a csv desc_b txt desc_c
The text was updated successfully, but these errors were encountered: