mirror of
https://github.com/foomo/gograpple.git
synced 2025-10-16 12:35:37 +00:00
33 lines
457 B
Go
33 lines
457 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(versionCmd)
|
|
}
|
|
|
|
// set on build
|
|
var version = ""
|
|
|
|
var (
|
|
versionCmd = &cobra.Command{
|
|
Use: "version",
|
|
Short: "prints cli version",
|
|
Long: "prints the current installed cli version",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Println(getVersion())
|
|
},
|
|
}
|
|
)
|
|
|
|
func getVersion() string {
|
|
if version == "" {
|
|
return "latest"
|
|
}
|
|
return version
|
|
}
|