code.cloudfoundry.org/cli@v7.1.0+incompatible/cf/commands/version.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/cf" 7 "code.cloudfoundry.org/cli/cf/commandregistry" 8 "code.cloudfoundry.org/cli/cf/flags" 9 . "code.cloudfoundry.org/cli/cf/i18n" 10 "code.cloudfoundry.org/cli/cf/requirements" 11 "code.cloudfoundry.org/cli/cf/terminal" 12 "code.cloudfoundry.org/cli/version" 13 ) 14 15 type Version struct { 16 ui terminal.UI 17 } 18 19 func init() { 20 commandregistry.Register(&Version{}) 21 } 22 23 func (cmd *Version) MetaData() commandregistry.CommandMetadata { 24 return commandregistry.CommandMetadata{ 25 Name: "version", 26 Description: T("Print the version"), 27 Usage: []string{ 28 "CF_NAME version", 29 "\n\n ", 30 T("'{{.VersionShort}}' and '{{.VersionLong}}' are also accepted.", map[string]string{ 31 "VersionShort": "cf -v", 32 "VersionLong": "cf --version", 33 }), 34 }, 35 } 36 } 37 38 func (cmd *Version) SetDependency(deps commandregistry.Dependency, pluginCall bool) commandregistry.Command { 39 cmd.ui = deps.UI 40 return cmd 41 } 42 43 func (cmd *Version) Requirements(requirementsFactory requirements.Factory, context flags.FlagContext) ([]requirements.Requirement, error) { 44 reqs := []requirements.Requirement{} 45 return reqs, nil 46 } 47 48 func (cmd *Version) Execute(context flags.FlagContext) error { 49 cmd.ui.Say(fmt.Sprintf("%s version %s", cf.Name, version.VersionString())) 50 return nil 51 }