Add version command

This commit is contained in:
世界
2022-07-04 17:08:28 +08:00
parent 718b4afbf3
commit 792dc83778
5 changed files with 42 additions and 16 deletions

View File

@@ -0,0 +1,20 @@
package main
import (
"os"
"runtime"
C "github.com/sagernet/sing-box/constant"
F "github.com/sagernet/sing/common/format"
"github.com/spf13/cobra"
)
var commandVersion = &cobra.Command{
Use: "version",
Short: "Print current version of sing-box",
Run: printVersion,
}
func printVersion(cmd *cobra.Command, args []string) {
os.Stderr.WriteString(F.ToString("sing-box version ", C.Version, " (", runtime.Version(), " ", runtime.GOOS, "/", runtime.GOARCH, ")\n"))
}