2021-07-25 02:02:05 +02:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2021-09-27 16:26:18 +02:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2021-07-25 02:02:05 +02:00
|
|
|
)
|
|
|
|
|
2021-09-27 16:26:18 +02:00
|
|
|
var Version = "dev"
|
2021-07-25 02:02:05 +02:00
|
|
|
|
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") {
|
2021-09-27 16:26:18 +02:00
|
|
|
JsonOutput(map[string]string{"version": Version}, nil, o)
|
2021-07-25 02:02:05 +02:00
|
|
|
return
|
|
|
|
}
|
2021-09-27 16:26:18 +02:00
|
|
|
fmt.Println(Version)
|
2021-07-25 02:02:05 +02:00
|
|
|
},
|
|
|
|
}
|