Skip to content

Commit

Permalink
Merge pull request #40 from nekonenene/develop
Browse files Browse the repository at this point in the history
Release 2022-12-10 14:09
  • Loading branch information
nekonenene authored Dec 10, 2022
2 parents 7472969 + 2ff875c commit a6d47ca
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions cmd/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"runtime/debug"
)

type parameters struct {
Expand All @@ -21,7 +22,7 @@ type parameters struct {
}

var params parameters
var Version = "v1.7.0"
var Version = "" // Overwrite when building

func ParseParameters() {
flag.StringVar(&params.GitHubAPIToken, "token", "", "[Required] GitHub API Token")
Expand All @@ -40,7 +41,7 @@ func ParseParameters() {
flag.Parse()

if params.ShowVersion {
fmt.Println(Version)
fmt.Println(getVersionString())
os.Exit(0)
}
if params.GitHubAPIToken == "" {
Expand All @@ -53,3 +54,18 @@ func ParseParameters() {
log.Fatalln("-repo-name is required")
}
}

func getVersionString() string {
// For downloading a binary from GitHub Releases
if Version != "" {
return Version
}

// For `go install`
i, ok := debug.ReadBuildInfo()
if ok {
return i.Main.Version
}

return "Development version"
}

0 comments on commit a6d47ca

Please sign in to comment.