Skip to content

Add version command #10

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

Merged
merged 2 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ builds:
- linux
- darwin
- windows
ldflags:
- -s -w -X github.com/similarweb/kubectl-interactive/cmd.Version="{{.Version}}" -X github.com/similarweb/kubectl-interactive/cmd.Commit={{.Commit}} -X github.com/similarweb/kubectl-interactive/cmd.date={{.Date}} -X github.com/similarweb/kubectl-interactive/cmd.builtBy=goreleaser
ignore:
- goos: darwin
goarch: 386
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Execute:
```
➜ kubectl interactive --help

Kubectl-interactive is an interactive kubectl command which wraps kubectl commands.
Kubectl-interactive is an interactive kubectl plugin which wraps kubectl commands.

Examples:

Expand All @@ -106,6 +106,11 @@ Examples:

Usage:
interactive command [resource name] [flags]
interactive [command]

Available Commands:
help Help about any command
version Print the kubectl-interactive version

Flags:
-A, --all-namespaces If present, list the requested object(s) across all namespaces
Expand All @@ -117,6 +122,8 @@ Flags:
-n, --namespace string If present, the namespace scope for this CLI request
-r, --random If present, one of the resources will select automatically
-s, --select-cluster Select cluster from .kube config file

Use "interactive [command] --help" for more information about a command.
```

# Contributing
Expand Down
30 changes: 30 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var (
// Version of the release, the value injected by .goreleaser
Version = `{{.Version}}`
// Commit hash of the release, the value injected by .goreleaser
Commit = `{{.Commit}}`
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the kubectl-interactive version",
Args: cobra.NoArgs,
RunE: runVersion,
}

func init() {
rootCmd.AddCommand(versionCmd)
}

func runVersion(cmd *cobra.Command, _ []string) error {
fmt.Printf("Kubectl-interactive %s (%s)", Version, Commit)
return nil
}