You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.
Almost(?) all command line programs will have the --help option so IMO it would make sense to either support it out of the box or at least make it simpler to implement it than currently as it involves many steps:
Call bindProcessName() (it's not going to be used for anything else than the usage message).
Add bool help to the options struct.
Bind -h and --help to it.
Call usage() if help is true.
I'd rather have a way to tell parse() to do all of this automatically, but this would require changing its return type, as we need to know whether help was requested or not, so maybe a better idea would be to add another method, e.g. parse_or_give_help() returning bool.
OTOH I think it's quite wrong for parse() to throw on command line syntax errors, this is not something exceptional and can (and does) happen all the time. So personally I'd rather change parse() to return an enum indicating whether the command line was successfully parsed, an error occurred or help was requested.
The text was updated successfully, but these errors were encountered:
Yeah, I've had all the same thoughts - and a few ideas about how to address them - but not been entirely satisfied with any of them yet.
Still thinking...
The new version of Clara, which has been completely rewritten (warning: very breaking changes), now has a dedicated Help() parser which, I believe, does what you want.
Also the new Clara uses a Result type for error propagation, rather than exceptions. Hopefully this is much closer to what you wanted (if you're still interested - obviously your original issue was raised a while ago)
Almost(?) all command line programs will have the
--help
option so IMO it would make sense to either support it out of the box or at least make it simpler to implement it than currently as it involves many steps:bindProcessName()
(it's not going to be used for anything else than the usage message).bool help
to the options struct.-h
and--help
to it.usage()
ifhelp
is true.I'd rather have a way to tell
parse()
to do all of this automatically, but this would require changing its return type, as we need to know whether help was requested or not, so maybe a better idea would be to add another method, e.g.parse_or_give_help()
returning bool.OTOH I think it's quite wrong for
parse()
to throw on command line syntax errors, this is not something exceptional and can (and does) happen all the time. So personally I'd rather changeparse()
to return an enum indicating whether the command line was successfully parsed, an error occurred or help was requested.The text was updated successfully, but these errors were encountered: