-
Notifications
You must be signed in to change notification settings - Fork 31
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 cli flag --version
to show version of spanner-cli
#198
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.
Thank you for sending this PR.
if !ok { | ||
return "(devel)" | ||
} | ||
return info.Main.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.
Does this work? It looks like info.Main.Version
still always returns (devel)
...? https://groups.google.com/g/golang-nuts/c/ObM-ilI7sio
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.
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.
FYI: I believe it should be only valid in go install
with tags.
Released binary should use another mechanism like LDFLAGS
. (spanner-cli recently don't have release binaries).
I think you all are Japanese so I introduce this article.
https://rhysd.hatenablog.com/entry/2021/06/27/222254
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.
Oh I didn't know that. Then maybe we can merge this PR and see how it goes.
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 looks like pkg.go.dev correctly recognizes the version of spanner-cli from git tag: https://pkg.go.dev/github.com/cloudspannerecosystem/spanner-cli
FYI: I believe it should be only valid in go install with tags.
Do you mean go install github.com/cloudspannerecosystem/spanner-cli@latest
always shows latest
? Or does it show the git tag associated with the latest git commit?
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.
Thank you all for the information! The official installation of spanner-cli is go install
as mentioned in README, so it looks like we don't need to manually embed the version information.
If it's fine, I'll go ahead and merge this PR.
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.
Do you mean go install github.com/cloudspannerecosystem/spanner-cli@latest always shows latest? Or does it show the git tag associated with the latest git commit?
Oh, that was not precise answer.
It always shows module version when go install
-ed, so it can print version even if not tagged.(go install *@latest
use latest released module version)
$ go install github.com/cloudspannerecosystem/wrench@9432313
go: downloading github.com/cloudspannerecosystem/wrench v1.10.2-0.20241120031843-9432313f606f
$ wrench --version
v1.10.2-0.20241120031843-9432313f606f
$ go install github.com/cloudspannerecosystem/wrench@latest
go: downloading github.com/cloudspannerecosystem/wrench v1.10.1
$ wrench --version
v1.10.1
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.
Thank you, sounds good.
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 merged the PR and put the tag v0.10.9
: https://github.com/cloudspannerecosystem/spanner-cli/releases/tag/v0.10.9
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.
Hello. Thank you for maintaining very useful cli for spanner!
What
SSIA
Why
It is more useful for troubleshooting if spanner-cli can show its version.
Implementation
I intentionally added
Version
tospannerOptions
, though it might be not good idea to do so because it seems that--version
is not a option to execute spanner-cli, but a kind of sub-command.The reason why I did so is that I feel it is difficult to show description of
--version
if I don't addVersion
tospannerOptions
.As an alternative, I considered to parse
os.Args
like below. But as I mentioned above it it difficult to show description of--version
whenspanner-cli --help
is executed.Please give me your opinion.