-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax for combined short option and value #78
Labels
Comments
It’s super weird to use an equals sign with a short argument, even weirder than omitting one with a long argument. I’d prefer not to support it. |
shadowspawn
added a commit
that referenced
this issue
Mar 12, 2022
…ined short and value (#75) 1) Refactor parsing to use independent blocks of code, rather than nested cascading context. This makes it easier to reason about the behaviour. 2) Split out small pieces of logic to named routines to improve readability, and allow extra documentation and examples without cluttering the parsing. (Thanks to @aaronccasanova for inspiration.) 3) Existing tests untouched to make it clear that the tested functionality has not changed. 4) Be more explicit about short option group expansion, and ready to throw error in strict mode for string option in the middle of the argument. (See #11 and #74.) 5) Add support for short option combined with value (without intervening `=`). This is what Commander and Open Group Utility Conventions do, but is _not_ what Yargs does. I don't want to block PR on this and happy to comment it out for further discussion if needed. (I have found some interesting variations in the wild.) [Edit: see also #78] 6) Add support for multiple unit tests files. Expand tests from 33 to 113, but many for internal routines rather than testing exposed API. 7) Added `.editorconfig` file Co-authored-by: Jordan Harband <[email protected]> Co-authored-by: Aaron Casanova <[email protected]>
Will reopen if becomes relevant again. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #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.The text was updated successfully, but these errors were encountered: