Skip to content

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

@markdingo

Description

@markdingo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions