-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add mode for optional option-argument from embedded value only (POSIX style) #1901
Comments
I haven't contributed to open source before and am not really acquainted with testing, but this look like something I could work on. I will try once I am finished with my current project. I think a better name would be An important question is also how we want to inform users about the correct syntax. All solutions I can think of are a bit awkward. One is to format all of them like this:
|
I like Yes, the help syntax is interesting. Maybe I'll do another look around at how this gets displayed. There must be plenty of applications using getsopts_long of which some use optional option arguments... |
I found these examples of utilities with "strict optional option arguments":
Details: The documentation for make is inaccurate, since it requires |
The |
This issue has not had any activity in over six months. It isn't likely to get acted on due to this report. This is a favourite of mine since the POSIX embedded-only approach is a standard and avoids a bunch of ambiguous parsing situations, but only one person has responded. Closing this and see if there is future interest! Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
Short version: support POSIX style parsing mode which only reads optional value with embedded forms
--optional=VALUE
and-oVALUE
.Say:
program.optionOptionalValuesEmbedded()
(Shorter meaningful name suggestions welcome!)
Long version
Commander supports an option which may be used as a boolean option but may optionally take an option-argument (declared with square brackets like
-o, --opt [value]
). This can lead to parsing ambiguities due to the space-separatedVALUE
being confused with non-option arguments.These are all the optional variations:
POSIX takes a stricter approach, which avoids the parsing ambiguity. The option-argument has to be embedded with the option.
So the POSIX approach only allows:
Reference:
The text was updated successfully, but these errors were encountered: