These are chat archives for kbknapp/clap-rs
In the sample code, in case the subcommand is not passed, is there a simple way to print help and exit gracefully? Currently it prints help but exits with code 1.
I checked for
AppSettings, but couldn't find anything suitable. Alternatively, I could use
get_matches_safe and process the result myself, but that's already getting complicated.
SubcommandRequiredElseHelpwill exit with a code of 1 because it was technically (although this is debatable) an error. i.e. the user failed to do something and got a message.
stdoutin both of those cases, whereas in
SubcommandRequiredElseHelpit's printed to
Thanks @kbknapp !
I'm still a bit curious. Reading the API doc for
Specifies that the help text should be displayed (before exiting gracefully) if no SubCommands are present at runtime (i.e. an empty run such as $ myprog).
shouldn't my sample already exit gracefully? Or I'm misunderstanding something.