v2 will implement the spf13/pflag library to enforce POSIX/GNU style flags (--flags | -f | -fsa).
Benefits
- One declaration per flag
pflag's BoolP("natures", "n", false, ...) binds the long and short name to a single variable. Today every flag is registered twice (a --natures bool and a separate -n bool) and each command has to OR them together (*mf.Natures || *mf.ShortNatures).
pflag removes the duplicate fields, the duplicate registrations, and the risk of the long/short pair silently drifting apart.
- True POSIX/GNU parsing
- Single-char flags can be stacked (
-asm == -a -s -m), and --long vs -s is actually enforced. stdlib flag treats -natures and --natures as identical, so the CLI doesn't match the convention its own help text advertises.
v2will implement thespf13/pflaglibrary to enforce POSIX/GNU style flags (--flags | -f | -fsa).Benefits
pflag'sBoolP("natures", "n", false, ...)binds the long and short name to a single variable. Today every flag is registered twice (a--naturesbool and a separate-nbool) and each command has to OR them together (*mf.Natures || *mf.ShortNatures).pflagremoves the duplicate fields, the duplicate registrations, and the risk of the long/short pair silently drifting apart.-asm==-a -s -m), and--longvs-sis actually enforced. stdlibflagtreats-naturesand--naturesas identical, so the CLI doesn't match the convention its own help text advertises.