Skip to content

Commit

Permalink
main: complain if there are extra args (occasionally i use the wrong …
Browse files Browse the repository at this point in the history
…flag for -e; this makes the mistake clearer)
  • Loading branch information
jrockway committed Jan 2, 2022
1 parent 49577ce commit 9f9c049
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/jlog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func main() {
panic(err)
}

if _, err := fp.Parse(); err != nil {
extraArgs, err := fp.Parse()
if err != nil {
if ferr, ok := err.(*flags.Error); ok && ferr.Type == flags.ErrHelp {
fmt.Fprintf(os.Stderr, "jlog - Search and pretty-print your JSON logs.\nMore info: https://github.com/jrockway/json-logs\n")
fmt.Fprintf(os.Stderr, "Version %s (%s) built on %s by %s\n", version, commit, date, builtBy)
Expand All @@ -75,6 +76,10 @@ func main() {
fmt.Fprintf(os.Stderr, "flag parsing: %v\n", err)
os.Exit(3)
}
if len(extraArgs) > 0 {
fmt.Fprintf(os.Stderr, "unexpected command-line arguments after flag parsing: %v\n", extraArgs)
os.Exit(1)
}
var f *os.File
if gen.Profile != "" {
var err error
Expand Down

0 comments on commit 9f9c049

Please sign in to comment.