open-vault/command/version.go

63 lines
1.2 KiB
Go
Raw Normal View History

2015-03-04 07:03:24 +00:00
package command
import (
2017-09-05 04:05:41 +00:00
"strings"
2015-11-09 18:52:55 +00:00
"github.com/hashicorp/vault/version"
2015-03-04 07:03:24 +00:00
"github.com/mitchellh/cli"
2017-09-05 04:05:41 +00:00
"github.com/posener/complete"
2015-03-04 07:03:24 +00:00
)
2017-09-05 04:05:41 +00:00
// Ensure we are implementing the right interfaces.
var _ cli.Command = (*VersionCommand)(nil)
var _ cli.CommandAutocomplete = (*VersionCommand)(nil)
2015-03-04 07:03:24 +00:00
// VersionCommand is a Command implementation prints the version.
type VersionCommand struct {
2017-09-05 04:05:41 +00:00
*BaseCommand
2015-11-09 18:52:55 +00:00
VersionInfo *version.VersionInfo
2017-09-05 04:05:41 +00:00
}
func (c *VersionCommand) Synopsis() string {
return "Prints the Vault CLI version"
2015-03-04 07:03:24 +00:00
}
func (c *VersionCommand) Help() string {
2017-09-05 04:05:41 +00:00
helpText := `
Usage: vault version
Prints the version of this Vault CLI. This does not print the target Vault
server version.
Print the version:
$ vault version
There are no arguments or flags to this command. Any additional arguments or
flags are ignored.
`
return strings.TrimSpace(helpText)
}
func (c *VersionCommand) Flags() *FlagSets {
return nil
}
func (c *VersionCommand) AutocompleteArgs() complete.Predictor {
return nil
}
func (c *VersionCommand) AutocompleteFlags() complete.Flags {
return nil
2015-03-04 07:03:24 +00:00
}
func (c *VersionCommand) Run(_ []string) int {
2016-11-28 00:32:57 +00:00
out := c.VersionInfo.FullVersionNumber(true)
if version.CgoEnabled {
out += " (cgo)"
}
2017-09-05 04:05:41 +00:00
c.UI.Output(out)
2015-03-04 07:03:24 +00:00
return 0
}