-
Notifications
You must be signed in to change notification settings - Fork 889
chore: version
sub command remove --version
and -v
flag
#2090
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this one up! 👍🏻
cli/root.go
Outdated
func versionCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "version", | ||
Short: "Version for coder", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: I think this reads a bit better, but up to you to include or not.
Short: "Version for coder", | |
Short: "Show coder version", |
cli/root.go
Outdated
cmd.Flags().BoolP("placeholder", "v", false, "This flag is a placeholder to make the cobra version flag work appropriately") | ||
_ = cmd.Flags().MarkHidden("placeholder") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cobra doesn't add this flag if Version
isn't specified in the root. I'd propose that being a cleaner alternative.
Having --version
and coder version
seems unnecessary to me. I'd prefer to have coder version
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m fine with only having version
but having both is consistent with help
(or do I misremember?) and I think covers a common use case. I.e. there’s a 50/50 chance someone will blindly do either --version
or version
instead of checking help 😄.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how Go just does go version
. I haven't found it to be confusing tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct cobra does not. However if we want to support --version
, we would need a persistent pre-run function to support the flag. Cobra has some first class support for --version
that works even if there are extra args, eg: coder --version workspaces
.
I think it is reasonable to use their first class support for this reason.
As for --version
or coder version
. I don't see anything wrong with supporting both. It's nice as a user to do w/e is more familiar to you.
Maybe coder version
can report more info like the version of the deployment you are logged into.
Examples:
git version
&git --version
docker --version
is less verbose thandocker version
docker-compose --version
is less verbose thandocker-compose version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to support both, I don't really understand why we need to though. Seems like supporting coder version
is fine, and supporting both seems to not really satisfy a need, but adds an additional user-contract for us to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll drop the flag for now then and just do coder version
version
sub command and reserve -v
flag on root.version
sub command remove --version
and -v
flag
What this does (#1543)
Removes
coder -v
andcoder --version
.Now do
coder version
to see coder version.