Skip to content

Commit

Permalink
remove --check shorthand and add global flags to version cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhelfand authored and tekton-robot committed Dec 17, 2020
1 parent b9995d1 commit 05a7da3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
9 changes: 6 additions & 3 deletions docs/cmd/tkn_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ Prints version information
### Options

```
--check check if a newer version is available
-h, --help help for version
-n, --namespace string namespace to check installed controller version
--check check if a newer version is available
-c, --context string name of the kubeconfig context to use (default: kubectl config current-context)
-h, --help help for version
-k, --kubeconfig string kubectl config file (default: $HOME/.kube/config)
-n, --namespace string namespace to check installed controller version
-C, --no-color disable coloring (default: false)
```

### SEE ALSO
Expand Down
12 changes: 12 additions & 0 deletions docs/man/man1/tkn-version.1
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,26 @@ Prints version information
\fB\-\-check\fP[=false]
check if a newer version is available

.PP
\fB\-c\fP, \fB\-\-context\fP=""
name of the kubeconfig context to use (default: kubectl config current\-context)

.PP
\fB\-h\fP, \fB\-\-help\fP[=false]
help for version

.PP
\fB\-k\fP, \fB\-\-kubeconfig\fP=""
kubectl config file (default: $HOME/.kube/config)

.PP
\fB\-n\fP, \fB\-\-namespace\fP=""
namespace to check installed controller version

.PP
\fB\-C\fP, \fB\-\-no\-color\fP[=false]
disable coloring (default: false)


.SH SEE ALSO
.PP
Expand Down
10 changes: 7 additions & 3 deletions pkg/cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/flags"
"github.com/tektoncd/cli/pkg/version"
)

Expand Down Expand Up @@ -54,6 +55,9 @@ func Command(p cli.Params) *cobra.Command {
Annotations: map[string]string{
"commandType": "utility",
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return flags.InitParams(p, cmd)
},
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Fprintf(cmd.OutOrStdout(), "Client version: %s\n", clientVersion)

Expand Down Expand Up @@ -89,12 +93,12 @@ func Command(p cli.Params) *cobra.Command {

cmd.Flags().StringVarP(&namespace, "namespace", "n", namespace,
"namespace to check installed controller version")
flags.AddTektonOptions(cmd)

if skipCheckFlag != "true" {
cmd.Flags().BoolVarP(&check, "check", "c", false, "check if a newer version is available")
_ = cmd.Flags().MarkShorthandDeprecated("check",
"the -c shorthand for tkn version --check will be removed in v0.15.0. See https://github.com/tektoncd/cli/issues/1231.")
cmd.Flags().BoolVar(&check, "check", false, "check if a newer version is available")
}

return cmd
}

Expand Down

0 comments on commit 05a7da3

Please sign in to comment.