If the SYNOPSIS of a standard utility shows an option with a mandatory option-argument (as with [ -c option_argument] in the example), a conforming application shall use separate arguments for that option and its option-argument. However, a conforming implementation shall also permit applications to specify the option and option-argument in the same argument string without intervening characters.
An option and its argument may or may not appear as separate tokens. (In other words, the whitespace separating them is optional.) Thus, -o foo and -ofoo are equivalent.
getopts_long
For an option with a mandatory option-argument, -o foo and -ofoo are equivalent.
Commander
For an option with a mandatory option-argument, -o foo and -ofoo are equivalent.
Minimist
Has some complex cases about other syntax that are accepted after the short option, but the main syntax is for an option expecting an argument that -o foo and -o=foo are equivalent.
Yargs
Has some complex cases about other syntax that are accepted after the short option, but the main syntax is for an option expecting an argument that -o foo and -o=foo are equivalent.
For a
type: string
option I would like to support-sVALUE
for consistency with POSIX compatible implementations.But should we also support
-s=VALUE
?! Three reasons for suggesting=
form:--string=value
Caveat: this makes the equals special, and in particular user wanting leading
=
on value would need to use-s =xxx
or-s==xxx
.For interest, various libraries supporting both forms:
Taking a look at the reference specifications and implementations I identified in https://github.com/pkgjs/parseargs/issues/76.
POSIX
Utility Conventions
GNU
Program Argument Syntax Conventions
getopts_long
For an option with a mandatory option-argument,
-o foo
and-ofoo
are equivalent.Commander
For an option with a mandatory option-argument,
-o foo
and-ofoo
are equivalent.Minimist
Has some complex cases about other syntax that are accepted after the short option, but the main syntax is for an option expecting an argument that
-o foo
and-o=foo
are equivalent.Yargs
Has some complex cases about other syntax that are accepted after the short option, but the main syntax is for an option expecting an argument that
-o foo
and-o=foo
are equivalent.