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 flag -v to show version #44

Merged
merged 1 commit into from
Apr 10, 2023
Merged

✨ Add flag -v to show version #44

merged 1 commit into from
Apr 10, 2023

Conversation

julien040
Copy link
Owner

To retrieve gut version, now you can run gut -v or gut version

To be able to run gut -v, I had to create a controller for the root cmd.
By default, if no controller is linked to a command, cobra will show the help.

Now, root has a controller : if the -v flag is present, it fetches the version from the telemetry package and prints it.
If not, it calls cmd.help() to show the help as before

I have also created a version cmd that does the same a gut -v.

The version is added to the build by goreleaser thanks to ldflags.
If gut is built from source, goreleaser is not used so the gut version can't be shown.
To remediate this, gut -v falls back to "You are running a built from source version of Gut"

To retrieve gut version, now you can run `gut -v` or `gut version`

To be able to run `gut -v`, I had to create a controller for the root cmd.
By default, if no controller is linked to a command, cobra will show the help.

Now, root has a controller : if the -v flag is present, it fetches the version from the telemetry package and prints it.
If not, it calls cmd.help() to show the help as before

I have also created a version cmd that does the same a `gut -v`.

The version is added to the build by goreleaser thanks to ldflags.
If gut is built from source, goreleaser is not used so the gut version can't be shown.
To remediate this, gut -v falls back to "You are running a built from source version of Gut"
@julien040 julien040 linked an issue Apr 10, 2023 that may be closed by this pull request
@julien040 julien040 added the enhancement New feature or request label Apr 10, 2023
@julien040 julien040 merged commit 2e90b6a into main Apr 10, 2023
@julien040 julien040 deleted the feature/version-cmd branch April 10, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A “--version” option would be helpful
1 participant