Skip to content

Commit

Permalink
Add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Sep 5, 2021
1 parent 705ad55 commit d8f1b91
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

var (
Version = ""
CommitSHA = ""

maxBranches = flag.Int("max-branches", 10, "Max amount of active branches to show")
maxCommits = flag.Int("max-commits", 10, "Max amount of commits to show")
maxIssues = flag.Int("max-issues", 10, "Max amount of issues to show")
Expand All @@ -26,6 +29,8 @@ var (
withCommits = flag.Bool("with-commits", false, "Show new commits")
allProjects = flag.Bool("all-projects", false, "Retrieve information for all source repositories")

version = flag.Bool("version", false, "display version")

theme Theme
)

Expand Down Expand Up @@ -203,6 +208,23 @@ func parseAllProjects() {

func main() {
flag.Parse()
if *version {
if len(CommitSHA) > 7 {
CommitSHA = CommitSHA[:7]
}
if Version == "" {
Version = "(built from source)"
}

fmt.Printf("gitty %s", Version)
if len(CommitSHA) > 0 {
fmt.Printf(" (%s)", CommitSHA)
}

fmt.Println()
os.Exit(0)
}

initTheme()

if err := initGitHub(); err != nil {
Expand Down

0 comments on commit d8f1b91

Please sign in to comment.