Skip to content

Commit

Permalink
Add explicit -h and -help flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed May 26, 2022
1 parent e3b0873 commit fb20688
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"flag"
"fmt"
"log"
"os"
"runtime/debug"

Expand All @@ -15,6 +16,8 @@ import (
var (
vPtr = flag.Bool("v", false, "")
versionPtr = flag.Bool("version", false, "")
hPtr = flag.Bool("h", false, "")
helpPtr = flag.Bool("help", false, "")
allPtr = flag.Bool("all", false, "")
passPtr = flag.Bool("pass", false, "")
skipPtr = flag.Bool("skip", false, "")
Expand Down Expand Up @@ -58,9 +61,9 @@ var (
)

func main() {
log.SetFlags(0)
flag.Usage = func() {
fmt.Fprint(os.Stdout, usage)
os.Exit(1)
fmt.Fprint(flag.CommandLine.Output(), usage)
}
flag.Parse()

Expand All @@ -71,6 +74,10 @@ func main() {
fmt.Fprintf(os.Stdout, "tparse version: %s\n", tparseVersion)
return
}
if *hPtr || *helpPtr {
fmt.Print(usage)
return
}
var format app.OutputFormat
switch *formatPtr {
case "basic":
Expand Down

0 comments on commit fb20688

Please sign in to comment.