Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add version flag #37

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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