Skip to content

Commit

Permalink
Merge pull request #38 from wbollock/feat/help_cli
Browse files Browse the repository at this point in the history
feat: cli help usage
  • Loading branch information
wbollock authored Jan 10, 2025
2 parents 6a98a64 + 3e16968 commit c00684c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func init() {
if err := viper.BindPFlag("request_limit_burst", flags.Lookup("request-limit-burst")); err != nil {
logger.SlogFatal("Could not bind request-limit-burst flag", "error", err)
}

flags.BoolP("help", "h", false, "Show help message")
if err := viper.BindPFlag("help", flags.Lookup("help")); err != nil {
logger.SlogFatal("Could not bind help flag", "error", err)
}

}

func main() {
Expand All @@ -91,6 +97,14 @@ func main() {
logger.SlogFatal("CLI parsing failed", "error", err)
}

if viper.GetBool("help") {
err := cli.Usage()
if err != nil {
logger.SlogFatal("Getting CLI usage failed", "error", err)
}
os.Exit(0)
}

// preserve deprecated verbose flag
if viper.GetBool("verbose") {
logger.Init("debug")
Expand Down

0 comments on commit c00684c

Please sign in to comment.