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

Proposal to Add -v or --version Parameter to CLI Interface #80

Open
gregoriopellegrino opened this issue Jun 27, 2023 · 3 comments
Open
Assignees

Comments

@gregoriopellegrino
Copy link

I would like to propose the addition of a new parameter, either -v or --version, to the command-line interface (CLI) of our tool. This parameter would allow users to quickly retrieve information about the version of the tool they are using.

Currently, when working with the CLI, it can be cumbersome to find the version of the tool.

@mickael-menu
Copy link
Member

Sure, good idea.

I would avoid hard-coding the current version though. We can use this snippet during build time to get the version number from the Git tags:

git describe --tags --match v[0-9]* 2> /dev/null

Cool thing is that between two versions you still get a descriptive version number, e.g. v0.11.1-2-gab1d8fd

@chocolatkey
Copy link
Member

This is very easy to do using goreleaser (which we already use). See https://goreleaser.com/cookbooks/using-main.version/
That might be all we need, but can also be overridden, e.g.

ldflags:
      - -s -w -X github.com/xxx/yyy/internal/consts.BuildCommit={{.Commit}} -X github.com/xxx/yyy/internal/consts.BuildTimestamp={{.Timestamp}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants