Skip to content

Commit

Permalink
Explicit help option
Browse files Browse the repository at this point in the history
  • Loading branch information
spacez320 committed Jan 19, 2025
1 parent a815229 commit 8d8ad23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cmd/shui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/spacez320/shui"
"github.com/spacez320/shui/internal/lib"
"github.com/spf13/pflag"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -105,6 +106,7 @@ func main() {
}

// Define arguments.
flag.Bool("help", false, "Show usage")
flag.Bool("history", viper.GetBool("history"), "Whether or not to use or preserve history.")
flag.Bool("show-help", viper.GetBool("show-help"), "Whether or not to show help displays.")
flag.Bool("show-logs", viper.GetBool("show-logs"), "Whether or not to show log displays.")
Expand Down Expand Up @@ -146,6 +148,12 @@ func main() {
flag.Parse()
viper.BindPFlags(flag.CommandLine)

// Display usage.
if viper.GetBool("help") {
pflag.Usage()
os.Exit(0)
}

// Display a version.
if viper.GetBool("version") {
fmt.Printf("shui %#v\n", buildInfo{
Expand Down
2 changes: 1 addition & 1 deletion cmd/shui/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestCLI(t *testing.T) {
testName string
cliArgs []string
}{
{"help", []string{"-h"}},
{"help", []string{"--help"}},
}

for _, cliTest := range cliTests {
Expand Down

0 comments on commit 8d8ad23

Please sign in to comment.