Skip to content

Shorthand only flags#10

Closed
ThinkChaos wants to merge 2 commits intoogier:masterfrom
ThinkChaos:master
Closed

Shorthand only flags#10
ThinkChaos wants to merge 2 commits intoogier:masterfrom
ThinkChaos:master

Conversation

@ThinkChaos
Copy link
Copy Markdown

I wanted flags that can only be specified as -f and not --f. Mainly because it allows for the help to look better.
I think this type of flag is mostly useful for bool flags, but I added convenience methods/functions for all flag types by adding S to the name: BoolS.
For BoolS("f", false, "blah") the help is: -f=false: blah.

Convenience functions for shorthand only flags
@ogier
Copy link
Copy Markdown
Owner

ogier commented Feb 15, 2015

Adding a whole bunch of extra methods with yet another cryptic suffix doesn't sound attractive. Hiding the shorthand in the name field is also very hacky, and probably makes error messages worse.

It would be much more elegant to make the Name field truly empty, and let people use the <type>P form of the method. That would mean some flags don't end up in the formal map, and VisitAll and friends might be tricky to implement. So for now I will close this PR.

@ogier ogier closed this Feb 15, 2015
ThinkChaos pushed a commit to ThinkChaos/pflag that referenced this pull request Feb 28, 2022
Declare Flag{ by name instead of order
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.

2 participants