myip/main.go

38 lines
625 B
Go
Raw Normal View History

2021-10-15 08:17:56 +00:00
package main
import (
"fmt"
2021-10-15 10:57:15 +00:00
"log"
2021-10-15 08:17:56 +00:00
"os"
2021-10-15 16:58:49 +00:00
"github.com/spf13/cobra"
"kumoly.io/tools/myip/cmd"
2021-10-15 08:17:56 +00:00
)
2021-10-15 10:57:15 +00:00
var Version = "v0.1.0"
2021-10-15 16:58:49 +00:00
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)
},
2021-10-15 08:17:56 +00:00
}
2021-10-15 16:58:49 +00:00
func init() {
log.SetFlags(0)
log.SetOutput(os.Stdout)
cmd.ClientCmd.Version = Version
cmd.ClientCmd.AddCommand(versionCmd)
cmd.ClientCmd.AddCommand(cmd.ServerCmd)
2021-10-15 08:17:56 +00:00
}
func main() {
2021-10-15 16:58:49 +00:00
if err := cmd.ClientCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
2021-10-15 10:57:15 +00:00
os.Exit(1)
}
}