Skip to content

Add a method to register the help flag#109

Open
keiichiw wants to merge 2 commits intorust-lang:masterfrom
keiichiw:add-help-flag
Open

Add a method to register the help flag#109
keiichiw wants to merge 2 commits intorust-lang:masterfrom
keiichiw:add-help-flag

Conversation

@keiichiw
Copy link

Fixes #108

When we add a flag with `reqopt()`, the mandatory flag is always
required. This behavior doesn't work well when we want to add a `help`
flag, which should work without the required flag is not specified like
`my_command --help`.

So, let's add `helpflag()` method, which add an optional flag "help"
which will allow `parse()` to skip checking the existence of mandatory
flags.
Since `helpflag()` method was added, we shouldn't use "help" as a
placeholder in tests unrelated to the helpflag() method.
@heroin-moose
Copy link

heroin-moose commented Jan 7, 2022

This issue also arises with -v or -V flags that used to show program version. So I think it should be a more generic option like

opts.optflagsingle("h", "help", "show help and exit");
opts.optflagsingle("v", "version", "show version info and exit");

or something like this.

@tgross35
Copy link
Contributor

@keiichiw this is a rather old PR, but any chance you're interested in updating it with that suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way of adding "help" flag which works with required options

3 participants