myip/main.go

39 lines
687 B
Go

package main
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
"kumoly.io/tools/myip/cmd"
)
var Version = "v0.1.0"
var Build = ""
var versionCmd = &cobra.Command{
Use: "version",
Short: "version",
Long: `Print the version number of myip`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(Version + "-" + Build)
},
}
func init() {
log.SetFlags(0)
log.SetOutput(os.Stdout)
cmd.ClientCmd.Version = Version + "-" + Build
cmd.ClientCmd.AddCommand(versionCmd)
cmd.ClientCmd.AddCommand(cmd.ServerCmd)
cmd.ClientCmd.AddCommand(cmd.LocalIPCmd)
}
func main() {
if err := cmd.ClientCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}