[QUESTION] Is it possible to make subcommands required, or how to output usage for subcommands? #2015
-
Is it possible to make subcommands required, so that if you don't specify them, it prints the help text? I didn't see anything in the docs and currently the best I can do is match Or, alternatively: Is there an easy way to output the help text for the missing subcommand? The best I could manage is I was following the instructions in the README and I'm using the YAML definitions. Maybe I'm missing something, I'm new to Rust. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
https://docs.rs/clap/2.33.1/clap/enum.AppSettings.html#variant.SubcommandRequiredElseHelp |
Beta Was this translation helpful? Give feedback.
-
Thanks, that's definitely something I missed! So, in case anybody else is looking for this too and is wondering how to do it from YAML: about: My project
settings:
- subcommandrequiredelsehelp
subcommands:
- foo:
about: First layer subcommand
settings:
- subcommandrequiredelsehelp
subcommands:
- bar:
about: Second layer subcommand or, more succinctly: about: My project
global_settings:
- subcommandrequiredelsehelp
subcommands:
- foo:
about: First layer subcommand
subcommands:
- bar:
about: Second layer subcommand |
Beta Was this translation helpful? Give feedback.
https://docs.rs/clap/2.33.1/clap/enum.AppSettings.html#variant.SubcommandRequiredElseHelp