-
Notifications
You must be signed in to change notification settings - Fork 150
Using AppSettings::SubcommandsNegateReqs #124
Copy link
Copy link
Closed
Labels
enhancementWe would love to have this feature! Feel free to supply a PRWe would love to have this feature! Feel free to supply a PRneed-designThe concrete desing is uncertain, please get involved in the discussion before sending a PRThe concrete desing is uncertain, please get involved in the discussion before sending a PRquestion
Metadata
Metadata
Assignees
Labels
enhancementWe would love to have this feature! Feel free to supply a PRWe would love to have this feature! Feel free to supply a PRneed-designThe concrete desing is uncertain, please get involved in the discussion before sending a PRThe concrete desing is uncertain, please get involved in the discussion before sending a PRquestion
I'm sorry if I'm missing something here, but I was unable to find any information on the documentation or in the examples.
I have a use case where my program has a required Arg (for example a input file name). I would like to implement shell completions generation using clap during runtime by passing a
completionssubcommand and the shell to generate the completions for (the same wayrustupdoes). For this to happen I need to setAppSettings::SubcommandsNegateReqs. Using the examples as a guide I did this:But now, when I run
cargo run completions zshfor example, my program panics atOpt::from_args()due to aNonebeenunwrap'd.I've found a workaround this by getting the clap matches via
Opt::clap().get_matches()and matching against the subcommands (and exiting early if the subcommand was found), but I found this very ugly and was thinking that there must be a clean way to do this usingstructopt.