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

Two commands cannot contain the same named flags #55

Open
lucymhdavies opened this issue Aug 25, 2019 · 0 comments
Open

Two commands cannot contain the same named flags #55

lucymhdavies opened this issue Aug 25, 2019 · 0 comments
Labels

Comments

@lucymhdavies
Copy link

lucymhdavies commented Aug 25, 2019

For example, I have

https://github.com/LMHD/lucli/blob/master/cmd/jess.go#L35-L36

	command.Flags().StringP("image", "i", "jess/firefox", "Image to use")
	command.BindFlags()

In my init function, I have

https://github.com/LMHD/lucli/blob/master/cmd/jess.go#L53

		image := cli.FlagValues().GetString("image")

For this command, the correct value is used (either the default, or user-specified)

$ luclidev jess
INFO[0000] Using image: jess/firefox
INFO[0000] Pulling image layers... please wait           image=jess/firefox

However, if I have another command (in my case named "generic") which uses the same named flag, then cli.FlagValues().GetString("image") returns the default value of the "image" flag from the other command.

As a workaround, I've renamed the flag in the new command:
LMHD/lucli@6c6d63a

lucymhdavies pushed a commit to LMHD/lucli that referenced this issue Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant