Skip to content

Commit 4d9d2b1

Browse files
committed
Add lazygit --v version
* Recover Rev and Build Date from build args * Moved `debuggingPointer` and `versionFlag` to `var()` * Print version and exit in case of `-v` or `--v`
1 parent 6cb0a14 commit 4d9d2b1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

main.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import (
1414
var (
1515
startTime time.Time
1616
debugging bool
17+
Rev string
18+
builddate string
19+
debuggingPointer = flag.Bool("debug", false, "a boolean")
20+
versionFlag = flag.Bool("v", false, "Print the current version")
1721
)
1822

1923
func homeDirectory() string {
@@ -58,11 +62,14 @@ func navigateToRepoRootDirectory() {
5862
}
5963

6064
func main() {
61-
debuggingPointer := flag.Bool("debug", false, "a boolean")
62-
flag.Parse()
65+
startTime = time.Now()
6366
debugging = *debuggingPointer
6467
devLog("\n\n\n\n\n\n\n\n\n\n")
65-
startTime = time.Now()
68+
flag.Parse()
69+
if *versionFlag {
70+
fmt.Printf("rev=%s, build date=%s", Rev, builddate)
71+
os.Exit(0)
72+
}
6673
verifyInGitRepo()
6774
navigateToRepoRootDirectory()
6875
run()

0 commit comments

Comments
 (0)