Add '-h, --help' flag to print help message then exit

This commit is contained in:
Alessio 2022-02-12 15:41:03 -08:00
parent 2773214855
commit 13170c84b2
3 changed files with 13 additions and 0 deletions

View File

@ -14,6 +14,9 @@ PATH=`pwd`:$PATH
test "$(tw --version)" = "v$FAKE_VERSION"
tw --help
test $? -eq 0
tw create_profile data
cd data

View File

@ -51,6 +51,9 @@ This application downloads tweets from twitter and saves them in a SQLite databa
<TARGET> is the search query. Should be wrapped in quotes if it has spaces.
<flags>:
-h, --help
Print this message, then exit.
-v, --version
Print the version number and exit.

View File

@ -28,6 +28,9 @@ func main() {
how_many := flag.Int("n", 50, "???")
flag.IntVar(how_many, "number", 50, "???")
help := flag.Bool("help", false, "???")
flag.BoolVar(help, "h", false, "???")
flag.Parse()
args := flag.Args()
@ -40,6 +43,10 @@ func main() {
os.Exit(0)
}
if *help {
die("", true, 0)
}
if len(args) < 2 {
die("", true, 1)
}