Skip to content

prevent removal of valid arguments - #95

Merged
smarterclayton merged 1 commit into
spf13:masterfrom
deads2k:deads-prevent-extra-removal
Apr 28, 2015
Merged

smarterclayton merged 1 commit into
spf13:masterfrom
deads2k:deads-prevent-extra-removal

Conversation

@deads2k

@deads2k deads2k commented Apr 24, 2015

Copy link
Copy Markdown
Contributor

running a command like:

openshift admin policy add-role-to-user admin my-user

where admin and my-user are arguments to the openshift admin policy add-role-to-user command, removes the admin argument (args[4]).

This pull stops removing more than one token from the args for command matches.

@smarterclayton Related to openshift/origin#1894

@smarterclayton

Copy link
Copy Markdown
Collaborator

Add a test case please.

@deads2k
deads2k force-pushed the deads-prevent-extra-removal branch from 800a992 to 8c78327 Compare April 24, 2015 17:07
@deads2k

deads2k commented Apr 24, 2015

Copy link
Copy Markdown
Contributor Author

test added.

@smarterclayton

Copy link
Copy Markdown
Collaborator

LGTM. @brendandburns can you review as well? Impacts kube in a few places.

Comment thread command.go Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being always the bikeshedder, I like this better (and think it's faster, more readable, more efficient...) What do you think?

https://gist.github.com/eparis/458542ddda01fa9850f9

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think?

I'm not against it, except for it not working:

[deads@deads-dev-01 cobra]$ go test
Error: unknown command "one"
Run 'print help' for usage.
--- FAIL: TestChildSameName (0.00 seconds)
    cobra_test.go:345: Wrong command called
    cobra_test.go:348: Command didn't parse correctly

I checked in a similar version that passes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k yeah, so I guess my version was actually mutating the original slice, rather than creating a new slice with just the correct data. Thanks for the new (working) version!

@deads2k
deads2k force-pushed the deads-prevent-extra-removal branch from 8c78327 to 36aee64 Compare April 28, 2015 11:58
@smarterclayton

Copy link
Copy Markdown
Collaborator

LGTM

smarterclayton added a commit that referenced this pull request Apr 28, 2015
@smarterclayton
smarterclayton merged commit af6b555 into spf13:master Apr 28, 2015
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.

3 participants