Skip to content

Commit

Permalink
feat: add the help flag (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tchoupinax authored Dec 14, 2023
1 parent f86a7c9 commit 988e7c1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
func main() {
// Check if the version is asked by flag
cliCommandDisplayVersion(os.Args)
// Check if the helper is asked by flag
cliCommandDisplayHelp(os.Args)

rootpath := getGitRootPath()

Expand Down
23 changes: 23 additions & 0 deletions manual.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"os"

"github.com/fatih/color"
)

func cliCommandDisplayVersion(args []string) {
displayVersion := StringInSlice("-h", args[1:]) || StringInSlice("--help", args[1:])

if displayVersion {
bold := color.New(color.Bold).SprintFunc()

fmt.Println()
fmt.Println(bold("⚡️ Git branch"))
fmt.Println()
fmt.Println("-h/--help: displays this menu")
fmt.Println()
os.Exit(0)
}
}
6 changes: 3 additions & 3 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"github.com/fatih/color"
)

const Version string = "0.0.11"
const BuildDate string = "2023-11-26"
const Version string = "0.0.12"
const BuildDate string = "2023-12-14"

func cliCommandDisplayVersion(args []string) {
func cliCommandDisplayHelp(args []string) {
displayVersion := StringInSlice("-v", args[1:]) || StringInSlice("--version", args[1:])

if displayVersion {
Expand Down

0 comments on commit 988e7c1

Please sign in to comment.