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! |
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,
-aSomethingparse as an option with argument, and-a Somethingwill 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.