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

Fix subcommand locations with NoOptDefValue flags #391

Merged
merged 1 commit into from
Feb 23, 2017

Conversation

eparis
Copy link
Collaborator

@eparis eparis commented Feb 9, 2017

If one ran a command like

./root --boolFlag subcmd1 subcmd2

Thing worked fine. The code recognized that --boolFlag followed by a
space meant the next word was not the argument to --boolFlag. But other
flag types with a NoOptDefValue (like a Count flag) would not ignore the
"argument". On a command like:

./root --countflag subcmd1 subcmd2

The processor, when looking for a subcommand, would first throw out the
--countflag subcmd1 and then look for subcmd2 under root.

The fix is to ignore the next word after any NoOptDefVal flag, not just
boolean flags.

If one ran a command like

./root --boolFlag subcmd1 subcmd2

Thing worked fine. The code recognized that --boolFlag followed by a
space meant the next word was not the argument to --boolFlag. But other
flag types with a NoOptDefValue (like a Count flag) would not ignore the
"argument".  On a command like:

./root --countflag subcmd1 subcmd2

The processor, when looking for a subcommand, would first throw out the
`--countflag subcmd1` and then look for subcmd2 under root.

The fix is to ignore the next word after any NoOptDefVal flag, not just
boolean flags.
@eparis
Copy link
Collaborator Author

eparis commented Feb 9, 2017

I believe this fixes spf13/pflag#112

ncw added a commit to rclone/rclone that referenced this pull request Feb 11, 2017
This is a temporary fix until this pull request gets merged

spf13/cobra#391

See original ticket

spf13/pflag#112
@ncw
Copy link
Contributor

ncw commented Feb 23, 2017

This patch works well for me - I've added it to the vendor branch for rclone.

@eparis eparis merged commit 92ea23a into spf13:master Feb 23, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants