Skip to content
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

Cannot create non-greedy option arguments, like --color option of GNU ls #8

Open
xenomachina opened this issue Feb 28, 2017 · 1 comment

Comments

@xenomachina
Copy link
Owner

The --help for GNU ls looks like:

      --color[=WHEN]         colorize the output; WHEN can be 'always' (default
                               if omitted), 'auto', or 'never'; more info below

You can say:

  • ls --color=never /tmp ← color has argument "never"
  • ls --color /tmp ← color has no argument, defaults to "auto"
  • ls --color never /tmp ← color has no argument, defaults to "auto" and "never" is treated as a positional argument

So the --color option has an optional argument, which it will only consume if it is in the same command-line argument.

With OptionArgumentIterator there is no way distinguish between --color=never and --color never, so it is currently impossible to simulate the behavior of this option.

Suggested fix: add a property to OptionArgumentIterator to indicate whether the first argument is "mandatory". A "storingWithDefault" convenience method could then be created that would consume an argument iff it is mandatory.

@xenomachina
Copy link
Owner Author

I'm changing this to an enhancement, as there is now a clear path for this to be done unambiguously, even though the feature doesn't yet exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant