1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-12-20 19:09:07 +01:00
juanfont.headscale/cmd/headscale/cli/version.go

28 lines
488 B
Go
Raw Normal View History

2021-07-25 02:02:05 +02:00
package cli
import (
"fmt"
"github.com/spf13/cobra"
"strings"
)
var version = "dev"
2021-07-25 15:09:53 +02:00
func init() {
rootCmd.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
2021-07-25 02:02:05 +02:00
Use: "version",
Short: "Print the version.",
Long: "The version of headscale.",
Run: func(cmd *cobra.Command, args []string) {
o, _ := cmd.Flags().GetString("output")
if strings.HasPrefix(o, "json") {
JsonOutput(map[string]string{"version": version}, nil, o)
return
}
fmt.Println(version)
},
}