tl;dr - By switching away from stdlib flag, we will be able to support a wider range of capabilities with significantly less workaround code.
Much of the code around here is arguably working around stdlib flag, for example:
- concept of commands
- nesting of commands
- commands with aliases
- persistent flags (in progress)
- flags with aliases
- flags of types not already supported in stdlib (via
FlagSet.Var)
- slice-specific (de)serialization hacks
- other inconsistently-implemented (de)serialization hacks
- probably other stuff!
By building on top of stdlib flag, we are limited to two categories of string arguments:
- flags
- must start with
-
- may accept zero or one argument
- non-flag string literals
- must not start with
-
- no additional help from stdlib
flag 🤷🏼
There are many other command line argument parsers available in the Go third-party package ecosystem such as:
- pflag, a lower-level library that provides a compatibility layer with stdlib
flag
- typically seen via this fork which isn't being actively maintained
- cobra, a holistic command and flag building solution that encourages imperative construction of command contexts (depends on pflag)
- kong, a holistic command and flag building solution with strong support for deriving applications from nested struct variables
- argparse, an imperative solution which aims to provide functionality like the Python stdlib
argparse
tl;dr - By switching away from stdlib
flag, we will be able to support a wider range of capabilities with significantly less workaround code.Much of the code around here is arguably working around stdlib
flag, for example:FlagSet.Var)By building on top of stdlib
flag, we are limited to two categories of string arguments:--flag🤷🏼There are many other command line argument parsers available in the Go third-party package ecosystem such as:
flagargparse