fix: Check for missing arguments and exit gracefully
This commit is contained in:
parent
f74ff68b76
commit
15736f91d9
6
main.go
6
main.go
@ -34,6 +34,12 @@ Examples:
|
|||||||
fmt.Fprintf(flag.CommandLine.Output(), helpMsg, exeName)
|
fmt.Fprintf(flag.CommandLine.Output(), helpMsg, exeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show help and exit if no arguments are provided
|
||||||
|
if len(os.Args) <= 1 {
|
||||||
|
flag.Usage()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
// Name, default val, help
|
// Name, default val, help
|
||||||
m := flag.String("m", "get", "Method for the request.")
|
m := flag.String("m", "get", "Method for the request.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user