You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you define a struct which only has positional arguments, the built in --help and --version are printed as part of the positional arguments, instead of the options on subcommands.
$ go run main.go --help
Usage: main [TEST]
Positional arguments:
TEST
Options:
--help, -h display this help and exit
--version display version and exit
But with a subcommand (with 1 or multiple positionals):
$ go run main.go --help
Usage: main <command> [<args>]
Options:
--help, -h display this help and exit
--version display version and exit
Commands:
posonly
$ go run main.go posonly --help
Usage: main posonly [INPUT [OUTPUT]]
Positional arguments:
INPUT
OUTPUT
--help, -h display this help and exit
--version display version and exit
$ go run main.go posonly --help
Usage: main posonly [--test TEST] [INPUT [OUTPUT]]
Positional arguments:
INPUT
OUTPUT
Options:
--test TEST, -t TEST [default: test]
--help, -h display this help and exit
--version display version and exit
The text was updated successfully, but these errors were encountered:
When you define a struct which only has positional arguments, the built in
--help
and--version
are printed as part of the positional arguments, instead of the options on subcommands.On the "root", it works as expected:
But with a subcommand (with 1 or multiple positionals):
But add an option:
The text was updated successfully, but these errors were encountered: