forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
49 lines (42 loc) · 1.24 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
package commands
import (
"fmt"
"github.com/cloudfoundry/cli/cf"
"github.com/cloudfoundry/cli/cf/commandregistry"
"github.com/cloudfoundry/cli/cf/flags"
. "github.com/cloudfoundry/cli/cf/i18n"
"github.com/cloudfoundry/cli/cf/requirements"
"github.com/cloudfoundry/cli/cf/terminal"
)
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 {
reqs := []requirements.Requirement{}
return reqs
}
func (cmd *Version) Execute(context flags.FlagContext) error {
cmd.ui.Say(fmt.Sprintf("%s version %s-%s", cf.Name, cf.Version, cf.BuiltOnDate))
return nil
}