-
Notifications
You must be signed in to change notification settings - Fork 63
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
Parse optional short options like gnu getopt #82
Conversation
Similar to rust-lang#49, this changes the parsing of short options to require no space between the option and argument. Now, `-aSomething` parse as an option with argument, and `-a Something` will parse as a present flag with a free non-option. This is a breaking change.
It's no longer necessary.
As far as I can tell GNU Getopt accepts whitespace between flag and the argument. From the Getopt Manual Example section:
As the non-space-separated variant looks similar to the case where multiple flags are concatenated (i.e. you can write |
On a second thought I recognize that this change is about flags with optional arguments. When I adjust the GNU Getopt example to use a double-colon for the So if this change only affects optional arguments all looks fine for me. The string generated by |
Ha, yes, I forgot to put that this is only a change to optional option arguments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jridgewell!
This commit reverts three recent PRs to the `getopts` crate. One of the main consumers of `getopts` is `rustc`, which isn't allowed to have breaking changes. In rust-lang#82, however, a breaking change was landed. It looks like rust-lang#83 builds on this change, and while rust-lang#81 seems unrelated the diffs were somewhat tangled.
Similar to #49, this changes the parsing of optional short options to require no space between the option and argument. Now,
-aSomething
parse as an option with argument, and-a Something
will parse as a present flag with a free non-option.Note that this only changes optional option arguments (when
hasarg = Maybe
, as inoptflagopt
). Required option arguments (whenhasarg = Yes
, as inoptopt
) still allow a space between the short option and its argument.This is a breaking change.