summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorjannfis <jann@mistrust.net>2020-09-27 21:34:05 +0200
committerGitHub <noreply@github.com>2020-09-27 21:34:05 +0200
commit881ad1bf523044f888eef8e5e69070481cdc4e97 (patch)
treecb33ae5b26fabfd0bfbaec7b085c063fe1c1cc7a /cmd
parentfa95873da285ee00713e4041d117ad37f43d899e (diff)
chore: Externalize version & build information (#104)
* chore: Externalize version information * Use full Git commit information * Introduce short and long version information * Typos * More typos
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmd/main.go b/cmd/main.go
index f5958d9..e4bb9f7 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -170,15 +170,25 @@ func newRootCommand() error {
// newVersionCommand implements "version" command
func newVersionCommand() *cobra.Command {
+ var short bool
var versionCmd = &cobra.Command{
Use: "version",
Short: "Display version information",
RunE: func(cmd *cobra.Command, args []string) error {
- fmt.Printf("%s\n", version.Useragent())
+ if !short {
+ fmt.Printf("%s\n", version.Useragent())
+ fmt.Printf(" BuildDate: %s\n", version.BuildDate())
+ fmt.Printf(" GitCommit: %s\n", version.GitCommit())
+ fmt.Printf(" GoVersion: %s\n", version.GoVersion())
+ fmt.Printf(" GoCompiler: %s\n", version.GoCompiler())
+ fmt.Printf(" Platform: %s\n", version.GoPlatform())
+ } else {
+ fmt.Printf("%s\n", version.Version())
+ }
return nil
},
}
-
+ versionCmd.Flags().BoolVar(&short, "short", false, "show only the version number")
return versionCmd
}