adds version command

This commit is contained in:
Marvin Steadfast 2021-01-22 09:34:45 +01:00
parent 06c32cb336
commit 3995469c67
2 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,9 @@ builds:
- "-s"
- "-w"
- "-extldflags '-static'"
- "-X go.xsfx.dev/wg-quicker/cmd.version={{.Version}}"
- "-X go.xsfx.dev/wg-quicker/cmd.commit={{.ShortCommit}}"
- "-X go.xsfx.dev/wg-quicker/cmd.date={{.Date}}"
hooks:
pre:
- make clean

View File

@ -2,6 +2,7 @@
package cmd
import (
"fmt"
"io/ioutil"
"os"
@ -10,6 +11,12 @@ import (
"go.xsfx.dev/wg-quicker/wgquick"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
var (
iface string
verbose bool
@ -33,6 +40,14 @@ var rootCmd = &cobra.Command{
},
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version informations",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("wg-quicker %s, commit %s, build on %s", version, commit, date) // nolint: forbidigo
},
}
var upCmd = &cobra.Command{
Use: "up [ config_file | interface ]",
Short: "Bringing interface up",
@ -117,6 +132,7 @@ func init() {
rootCmd.AddCommand(upCmd)
rootCmd.AddCommand(downCmd)
rootCmd.AddCommand(syncCmd)
rootCmd.AddCommand(versionCmd)
}
func Execute() {