adds version command
This commit is contained in:
parent
06c32cb336
commit
3995469c67
@ -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
|
||||
|
16
cmd/root.go
16
cmd/root.go
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user