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

require use of --option=value syntax #833

Closed
adeschamps opened this issue Jan 30, 2017 · 2 comments
Closed

require use of --option=value syntax #833

adeschamps opened this issue Jan 30, 2017 · 2 comments
Milestone

Comments

@adeschamps
Copy link

I'm looking at the follow option of the Unix tail command, and I'm not sure how to implement it. From the help output:

-f, --follow[={name|descriptor}]
                output appended data as the file grows;
                  an absent option argument means 'descriptor'

So the following are equivalent:

$ tail -f some-file
$ tail --follow some-file
$ tail --follow=descriptor some-file

Essentially, I think I need to only accept the = syntax, because in $ tail --follow some-file, some-file should be interpreted as a positional argument (in this case, the name of the file to print) and not as the value for the follow argument (which should default to descriptor). Is this possible?

@kbknapp
Copy link
Member

kbknapp commented Jan 30, 2017

There currently isn't a way to force use of the --option=value syntax. Although, I could add this as an opt-in feature.

You're right that --follow some-file would currently be interpretted as some-file being the value to --follow. There is a way to allow options to have no values (Arg::minimum_values(0)), you'd have to use either $ tail some-file --follow or $ tail --follow -- some-file have it parse correctly in current clap.

I'll add this to the new feature request issues and should be able to knock it out this week.

@kbknapp kbknapp changed the title Optional option where value is not required. require use of --option=value syntax Jan 30, 2017
@kbknapp kbknapp added this to the 2.21.0 milestone Jan 30, 2017
kbknapp added a commit that referenced this issue Feb 21, 2017
@homu homu closed this as completed in f002693 Feb 21, 2017
@adeschamps
Copy link
Author

Just wanted to say a very late thank you!

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

No branches or pull requests

2 participants