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 kubectl-neat version command #67

Merged
merged 2 commits into from
Jun 5, 2021
Merged

Add kubectl-neat version command #67

merged 2 commits into from
Jun 5, 2021

Conversation

amirschw
Copy link
Contributor

@amirschw amirschw commented Jun 4, 2021

Add "version" command to kubectl-neat.

Closes #63

~ $ kubectl-neat version
kubectl-neat version: v2.0.3-next

~ $ kubectl-neat version --help
Print the version of kubectl-neat

Usage:
  kubectl-neat version [flags]

Flags:
  -h, --help   help for version

Global Flags:
  -o, --output string   output format: yaml or json (default "yaml")

~ $ kubectl-neat --help
Usage:
  kubectl-neat [flags]
  kubectl-neat [command]

Examples:
kubectl get pod mypod -o yaml | kubectl neat
kubectl get pod mypod -oyaml | kubectl neat -o json
kubectl neat -f - <./my-pod.json
kubectl neat -f ./my-pod.json
kubectl neat -f ./my-pod.json --output yaml

Available Commands:
  get         
  help        Help about any command
  version     Print kubectl-neat version

Flags:
  -f, --file string     file path to neat, or - to read from stdin (default "-")
  -h, --help            help for kubectl-neat
  -o, --output string   output format: yaml or json (default "yaml")

Use "kubectl-neat [command] --help" for more information about a command.

Short: "Print kubectl-neat version",
Long: "Print the version of kubectl-neat",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("kubectl-neat version: %s\n", Version)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @itaysk, hope you're well :)

I started off with this basic implementation that only prints the version. Let me know if you would like to expand it by displaying other information like git commit or build date, and then perhaps also introduce a --short flag.

Also note that I am currently ignoring the persistent --output flag, as I couldn't find a good way to disable a global flag from a specific command. The version can of course be printed as JSON or YAML if you don't find it an overkill.

@itaysk
Copy link
Owner

itaysk commented Jun 4, 2021

Thanks @amirschw ! Nice to hear from you.
Looks good to me. My only comment is to maybe add the Version variable to the existing cmd.go file instead of creating a new file just for one variable. WDYT?

@amirschw
Copy link
Contributor Author

amirschw commented Jun 4, 2021

You too @itaysk! and thanks for kubectl-neat, we find it very useful here.
As for the comment - absolutely, I moved the variable to the cmd.go file. Should I squash the commits?

@itaysk
Copy link
Owner

itaysk commented Jun 5, 2021

Should I squash the commits?

I can do that as part of the merge

@itaysk itaysk merged commit f975c89 into itaysk:master Jun 5, 2021
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 this pull request may close these issues.

Suggestion: Add version flag
2 participants