by networked on 3/23/25, 12:45 PM with 98 comments
by acmj on 3/23/25, 2:27 PM
> options can have multiple values: -a 1 2 3 means that a is an array/slice/struct of three numbers of value [1,2,3]
Allowing multiple values is inconsistent because you can't tell in "./cmd -a 1 2 3" whether 2 and 3 are positional arguments or arguments for -a. This is not a GNU style. The GNU way is "./cmd -a 1 -a 2 -a 3" (or "./cmd -a 1,2,3"). This package supports that, which is good.
> option values can be separated by a space, equal sign, or nothing: -a1 -a=1 -a 1 are all equal
"--a=1" is a GNU style but "-a=1" is not. This is a minor issue, though.
Also, does this package support "--"? Everything following "--" should be treated as positional arguments.
by latchkey on 3/23/25, 2:39 PM
I'd just use cobra.
by CamouflagedKiwi on 3/23/25, 3:58 PM
Otherwise, I'm not really sure what this offers that alternatives don't, apart from the -a 1 2 3 -> [1,2,3] business which seems highly confusing and undesirable to me so I'd think of it as more of an anti-feature.
by edoceo on 3/23/25, 3:11 PM
I does everything, including too complicated options.
by odc on 3/23/25, 8:04 PM
by sandreas on 3/23/25, 3:24 PM
in the past and was pretty happy with it. However sometimes it's good to try something New :-)
by dotemacs on 3/23/25, 3:05 PM
I know of UNIX parameters, with a single hyphen & a single letter, and GNU parameters, with a double parameter and a word. But a single hyphen and then a word: *mind broken*.
When I first saw that on Terraform, I was upset & conflicted.
OK, I know that Java also has mental parameter options like that ('-version', note the *single* hyphen followed by, gasp, a word!), but I just dismissed it as weird enterprise-ism.
Then I saw that this 'single hyphen + word' was an accepted convention for parameters, in the Go world & I was disappointed.
Glad that this package is fighting the good fight.
by reactordev on 3/23/25, 3:58 PM
type Conf struct {
Thing string `argp:”name:thing;short:t;desc:A thing you can do”`
}
This would follow go struct tag standards.by typ on 3/24/25, 1:54 AM
by d_burfoot on 3/23/25, 3:12 PM
by friendzis on 3/24/25, 7:11 AM
[0]: https://docopt.org/
by amelius on 3/23/25, 2:30 PM
by declan_roberts on 3/23/25, 9:00 PM
by braggerxyz on 3/23/25, 5:09 PM
by namuol on 3/23/25, 11:19 PM
by synergy20 on 3/23/25, 9:21 PM
same to mycmd -v, mycmd --version
by thrill on 3/23/25, 3:45 PM
by jmclnx on 3/23/25, 2:52 PM
by arccy on 3/23/25, 2:26 PM
> * option values can be separated by a space, equal sign, or nothing: -a1 -a=1 -a 1 are all equal
> * options can have multiple values: -a 1 2 3 means that a is an array/slice/struct of three numbers of value [1,2,3]
while convenient, one of the reasons I dislike gnu style flags is just how inconsistent they can be and annoyingly hard to parse by humans