Skip to content

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.

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
2 participants