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

Add short version flag -v when not otherwise set #996

Merged

Conversation

hairyhenderson
Copy link
Contributor

Fixes #654 by adding a -v shorthand to the automatically-added version flag.

  • It will not add the shorthand if another -v shorthand is already set
  • It will not add the shorthand if another --version flag is already set

Signed-off-by: Dave Henderson dhenderson@gmail.com

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
@hairyhenderson
Copy link
Contributor Author

@eparis would you mind having a look at this?

@hairyhenderson
Copy link
Contributor Author

ping @jharshman, maybe?

@jharshman
Copy link
Collaborator

This looks pretty good to me! Thanks for addressing @eparis' concerns in #654.

@jharshman jharshman added the kind/feature A feature request for cobra; new or enhanced behavior label Feb 20, 2020
@hairyhenderson
Copy link
Contributor Author

Thanks @jharshman! Can this be merged? Or does it need more approvals?

@hairyhenderson
Copy link
Contributor Author

@jharshman @bep @eparis @broady I wonder if one of you could please merge this?

@jharshman
Copy link
Collaborator

@hairyhenderson - yes, I was just giving it another once over.

@jharshman jharshman merged commit 95f2f73 into spf13:master Feb 28, 2020
@hairyhenderson hairyhenderson deleted the optional-short-version-flag-654 branch February 28, 2020 18:43
@hairyhenderson
Copy link
Contributor Author

Thanks @jharshman, I appreciate it!

@hairyhenderson
Copy link
Contributor Author

@jharshman any possibility of getting a v0.0.7 cut? No rush - until then I can just use go get github.com/spf13/cobra@master.

edsantiago added a commit to edsantiago/libpod that referenced this pull request Sep 15, 2020
Three unrelated fixes to version output:

  * podman version --format json: was missing a newline
  * podman version --format TEMPLATE: had too many newlines

  * podman --version: would neither display version nor exit
    if followed by a subcommand ('podman --version ps')

The first two were easy: I used my best tweezers to delicately
pluck and transfer the misplaced \n and place it where needed.

The third was a doozy of a rabbit hole. As best I can tell,
a workaround was added in root.go to override cobra's built-in
Version handling, apparently to avoid having cobra add "-v"
as an alias for "--version". As best I can tell, cobra only
does this if the "-v" shortcut is not already taken (at
least as of Nov 2019: spf13/cobra#996 ).
Also as best I can tell that workaround is purely vestigial,
and removing it is safe. I've manually tested "-v" in podman run,
system df, and rm. I've run system tests.

Signed-off-by: Ed Santiago <santiago@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A feature request for cobra; new or enhanced behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Short --version flag (-v/--version)
2 participants