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

Simplify Version command #122

Closed
itsksaurabh opened this issue Aug 14, 2020 · 0 comments · Fixed by #123
Closed

Simplify Version command #122

itsksaurabh opened this issue Aug 14, 2020 · 0 comments · Fixed by #123

Comments

@itsksaurabh
Copy link
Contributor

Currently, The version of the cmd tool is set using an additional function which can be seen here.

The Cobra Library already has a feature to set the version using the underlying struct field Version.

// Version defines the version for this command. If this value is non-empty and the command does not
// define a "version" flag, a "version" boolean flag will be added to the command and, if specified,
// will print content of the "Version" variable. A shorthand "v" flag will also be added if the
// command does not define one.

    Version string

Official docs: https://github.com/spf13/cobra/blob/5cdf8e26ba7046dd743463f60102ab52602c6428/command.go#L90

My proposal to improve it :

	// RootCmd steals and anonymises databases
	RootCmd = &cobra.Command{
		Use:     "klepto",
		Version: version,  <======== Sets the version 
         .......
        ..................
}

I have already tested it and working as expected. Please check the output below:

$ ./testklepto --version
klepto version 0.0.0-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant