Skip to content

Commit

Permalink
Merge pull request #35 from harakeishi/fix/version
Browse files Browse the repository at this point in the history
バージョン表示がうまく動いていないので修正
  • Loading branch information
harakeishi committed Feb 25, 2022
2 parents 9aba3d5 + 2299050 commit 67dc66f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"fmt"
"os"
"runtime/debug"
"strings"

whris "github.com/harakeishi/whris/whris"
"github.com/spf13/cobra"
)

var Version = "dev"
var Ver = "dev"
var rootCmd = &cobra.Command{
Use: "whris",
Short: "`whris` is Displays management information for IPs associated with the domain.",
Expand All @@ -21,14 +22,12 @@ var rootCmd = &cobra.Command{
os.Exit(1)
}
if version {
if Version != "dev" {
fmt.Println(Version)

if strings.Contains(Ver, "dev") {
fmt.Println(Ver)
return nil
}
if buildInfo, ok := debug.ReadBuildInfo(); ok {
fmt.Println(buildInfo.Main.Version)

return nil
}
fmt.Println("unknown")
Expand All @@ -49,7 +48,7 @@ var rootCmd = &cobra.Command{
}

func Execute(ver string) {
Version = ver
Ver = ver
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
Expand Down

0 comments on commit 67dc66f

Please sign in to comment.