Skip to content

Commit

Permalink
support version command to show code-version for convenience
Browse files Browse the repository at this point in the history
Signed-off-by: Jianwei Mao <[email protected]>
  • Loading branch information
MaoJianwei committed Oct 13, 2024
1 parent 964afc8 commit a4023d5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
branch "MaoServerDiscovery/cmd"
"MaoServerDiscovery/util"
"errors"
"fmt"
"github.com/spf13/cobra"
"net"
"os"
Expand Down Expand Up @@ -137,6 +138,16 @@ var serverCmd = &cobra.Command{
},
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Mao: Show software version and code version.",
Long: "Mao-Service-Discovery: Show software version and code version.",
// Version: SERVER_VERSION,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("MaoServerDiscovery version " + ROOT_VERSION_SIGNATURE)
},
}

/**
Common:
- report_server_addr : connect to / listen on the addr, for service discovery
Expand Down Expand Up @@ -396,7 +407,7 @@ func main() {
util.MaoLog(util.INFO, "enable pprof: %v", http.ListenAndServe("0.0.0.0:39999", nil))
}()

rootCmd.AddCommand(generalClientCmd, serverCmd)
rootCmd.AddCommand(versionCmd, generalClientCmd, serverCmd)

if err := rootCmd.Execute(); err != nil {
//util.MaoLog(util.ERROR, fmt.Sprintf("Fail to execute rootCmd: %s", err))
Expand Down

0 comments on commit a4023d5

Please sign in to comment.