argp: GNU-style command line argument parser for Go
Published on: 2025-06-03 14:45:21
GNU command line argument parser
Command line argument parser following the GNU standard.
./test -vo out.png --size 256 input.txt
with the following features:
build-in help ( -h and --help ) message
and ) message scan arguments into struct fields with configuration in tags
scan into composite field types (arrays, slices, structs)
allow for nested sub commands
GNU command line argument rules:
arguments are options when they begin with a hyphen -
multiple options can be combined: -abc is the same as -a -b -c
is the same as long options start with two hyphens: --abc is one option
is one option option names are alphanumeric characters
options can have a value: -a 1 means that a has value 1
means that has value option values can be separated by a space, equal sign, or nothing: -a1 -a=1 -a 1 are all equal
are all equal options and non-options can be interleaved
the argument -- terminates all options so that all following arguments are treated as non-options
terminates all op
... Read full article.