Skip to content

Commit

Permalink
feat: add version flag (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh authored Mar 22, 2024
1 parent 39963e0 commit 94a1dd5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

var (
version = "dev" // populated by goreleaser
commit = "none" // populated by goreleaser
date = "unknown" // populated by goreleaser
configPath = flag.String("config", "", "")
promptPrefix = flag.String("prompt-prefix", " \ue0a0 ", "")
promptSuffix = flag.String("prompt-suffix", "", "")
Expand All @@ -30,6 +33,7 @@ var (
colorUntracked = flag.String("color-untracked", "magenta", "")
colorNoUpstream = flag.String("color-no-upstream", "bright-black", "")
colorMerging = flag.String("color-merging", "blue", "")
versionFlag = flag.Bool("version", false, "version for git-prompt-string")
)

func main() {
Expand Down Expand Up @@ -120,9 +124,22 @@ func main() {
cfg.ColorMerging = f.Value.String()
}
})

if !cfg.ColorEnabled {
color.Disable()
}

if *versionFlag {
fmt.Println()
fmt.Println("git-prompt-string")
fmt.Println("https://github.com/mikesmithgh/git-prompt-string")
fmt.Println()
fmt.Printf("Version: %s\n", version)
fmt.Printf("Commit: %s\n", commit)
fmt.Printf("BuildDate: %s\n", date)
os.Exit(0)
}

clearColor, err := color.Color("none")
if err != nil {
util.ErrMsg("color none", err, 0)
Expand Down

0 comments on commit 94a1dd5

Please sign in to comment.