-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
51 lines (43 loc) · 1.28 KB
/
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
package commands
import (
"fmt"
"code.cloudfoundry.org/cli/cf"
"code.cloudfoundry.org/cli/cf/commandregistry"
"code.cloudfoundry.org/cli/cf/flags"
. "code.cloudfoundry.org/cli/cf/i18n"
"code.cloudfoundry.org/cli/cf/requirements"
"code.cloudfoundry.org/cli/cf/terminal"
"code.cloudfoundry.org/cli/version"
)
type Version struct {
ui terminal.UI
}
func init() {
commandregistry.Register(&Version{})
}
func (cmd *Version) MetaData() commandregistry.CommandMetadata {
return commandregistry.CommandMetadata{
Name: "version",
Description: T("Print the version"),
Usage: []string{
"CF_NAME version",
"\n\n ",
T("'{{.VersionShort}}' and '{{.VersionLong}}' are also accepted.", map[string]string{
"VersionShort": "cf -v",
"VersionLong": "cf --version",
}),
},
}
}
func (cmd *Version) SetDependency(deps commandregistry.Dependency, pluginCall bool) commandregistry.Command {
cmd.ui = deps.UI
return cmd
}
func (cmd *Version) Requirements(requirementsFactory requirements.Factory, context flags.FlagContext) ([]requirements.Requirement, error) {
reqs := []requirements.Requirement{}
return reqs, nil
}
func (cmd *Version) Execute(context flags.FlagContext) error {
cmd.ui.Say(fmt.Sprintf("%s version %s", cf.Name, version.VersionString()))
return nil
}