Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to register the help flag #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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