-
Notifications
You must be signed in to change notification settings - Fork 62
/
cmd.go
44 lines (37 loc) · 1.09 KB
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright Contributors to the Open Cluster Management project
package version
import (
"fmt"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
"open-cluster-management.io/clusteradm/pkg/helpers"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
)
var example = `
# Version
%[1]s version
`
// NewCmd...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
o := newOptions(clusteradmFlags, streams)
cmd := &cobra.Command{
Use: "version",
Short: "get the versions of different components",
Long: "display versions of different components like: 'client' and 'server release'",
Example: fmt.Sprintf(example, helpers.GetExampleHeader()),
SilenceUsage: true,
RunE: func(c *cobra.Command, args []string) error {
if err := o.complete(c, args); err != nil {
return err
}
if err := o.validate(); err != nil {
return err
}
if err := o.run(); err != nil {
return err
}
return nil
},
}
return cmd
}