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

confusing documentation on parsing multiple subcommands (minor issue) #1434

Closed
0x900C5649 opened this issue Mar 20, 2019 · 2 comments · Fixed by #2685
Closed

confusing documentation on parsing multiple subcommands (minor issue) #1434

0x900C5649 opened this issue Mar 20, 2019 · 2 comments · Fixed by #2685
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations
Milestone

Comments

@0x900C5649
Copy link

I am working on a personal project for which I would like to parse a list of subcommands (together with their arguments).
So something like:

./myprogram generatelist --size 12 storelist mylist.txt

I wanted this to give me two subcommands (generatelist and storelist) with their arguments.

I thought this is possible because the [documentation] (https://docs.rs/clap/2.32.0/clap/enum.AppSettings.html#variant.ArgsNegateSubcommands) on AppSettings::ArgsNegateSubcommands states:

By default clap allows arguments between subcommands such as <cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]

As I couldn't make my program work I checked for more sources and found

  • Implement multiple subcommands at once #84 (which is marked as W: wont do)
  • The comment in clap/examples/20_subcommands.rs:
    // Notice only one command per "level" may be used. You could not, for example, do:
    //
    // $ git clone url push origin path

Both basically state, that what I wanted to do is not possible.

So my best guess is, that the documentation on AppSettings::ArgsNegateSubcommands assumes <cmd3> to be a subcommand of <cmd2>, which should be a subcommand of <cmd>

Possible fix

The simplest solution to avoid this confusion would probably be to rename the subcommands in the documentation to <cmd>, <subcmd> and <subsubcommand>

@ithinuel
Copy link

I had the exact same "adventure" than you.

@CreepySkeleton CreepySkeleton added A-docs Area: documentation, including docs.rs, readme, examples, etc... A-help Area: documentation, including docs.rs, readme, examples, etc... P3: want to have C-enhancement Category: Raise on the bar on expectations labels Feb 1, 2020
@CreepySkeleton CreepySkeleton added this to the 3.1 milestone Feb 1, 2020
@pksunkara
Copy link
Member

The actual issue is #2222 but leaving this issue open for docs fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants