adds version command
This commit is contained in:
parent
06c32cb336
commit
3995469c67
@ -18,6 +18,9 @@ builds:
|
|||||||
- "-s"
|
- "-s"
|
||||||
- "-w"
|
- "-w"
|
||||||
- "-extldflags '-static'"
|
- "-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:
|
hooks:
|
||||||
pre:
|
pre:
|
||||||
- make clean
|
- make clean
|
||||||
|
16
cmd/root.go
16
cmd/root.go
@ -2,6 +2,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -10,6 +11,12 @@ import (
|
|||||||
"go.xsfx.dev/wg-quicker/wgquick"
|
"go.xsfx.dev/wg-quicker/wgquick"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
version = "dev"
|
||||||
|
commit = "none"
|
||||||
|
date = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
iface string
|
iface string
|
||||||
verbose bool
|
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{
|
var upCmd = &cobra.Command{
|
||||||
Use: "up [ config_file | interface ]",
|
Use: "up [ config_file | interface ]",
|
||||||
Short: "Bringing interface up",
|
Short: "Bringing interface up",
|
||||||
@ -117,6 +132,7 @@ func init() {
|
|||||||
rootCmd.AddCommand(upCmd)
|
rootCmd.AddCommand(upCmd)
|
||||||
rootCmd.AddCommand(downCmd)
|
rootCmd.AddCommand(downCmd)
|
||||||
rootCmd.AddCommand(syncCmd)
|
rootCmd.AddCommand(syncCmd)
|
||||||
|
rootCmd.AddCommand(versionCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
|
Loading…
Reference in New Issue
Block a user