forked from vultr/vultr-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
52 lines (41 loc) · 930 Bytes
/
version.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
45
46
47
48
49
50
51
52
// Package version provides functionality to display the CLI version
package version
import (
"fmt"
"github.com/spf13/cobra"
"github.com/vultr/vultr-cli/v3/pkg/cli"
)
const (
Version string = "v3.4.0"
)
var (
long = `Displays current version of the Vultr-CLI`
example = `
# example
vultr-cli version
# Shortened with alias commands
vultr-cli v
`
)
// NewCmdVersion returns cobra command for version
func NewCmdVersion(base *cli.Base) *cobra.Command {
o := &options{Base: base}
cmd := &cobra.Command{
Use: "version",
Short: "Display the vultr-cli version",
Aliases: []string{"v"},
Long: long,
Example: example,
Run: func(cmd *cobra.Command, args []string) {
o.Base.Printer.Display(&VersionPrinter{Version: o.get()}, nil)
},
}
return cmd
}
type options struct {
Base *cli.Base
Version string
}
func (o *options) get() string {
return fmt.Sprintf("Vultr-CLI %s", Version)
}