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

Possible to have short flag without a long flag? #28

Open
markdingo opened this issue Jan 23, 2017 · 0 comments
Open

Possible to have short flag without a long flag? #28

markdingo opened this issue Jan 23, 2017 · 0 comments

Comments

@markdingo
Copy link

I'm probably missing something obvious, but how do I use pflag so that the only valid option is the short variant? That is, if I want just "-h" rather than something like "-h" and "--help"?

If I use:

flag.BoolVar(&help, "h", false, "Give help")

then Parse() requires --h

If I use:

flag.BoolVarP(&help, "", "h", false, "Give help")

then Parse() requires "-h" and the odd "--" whereas I was hoping an empty long-opt would have deactivated that variant.

I'm pretty sure that Posix/GNU do not insist on both variants of an option, but I've been wrong before.

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

No branches or pull requests

1 participant