diff options
| author | vin <git@vineetk.net> | 2023-11-15 13:20:19 -0500 |
|---|---|---|
| committer | vin <git@vineetk.net> | 2023-11-15 13:20:19 -0500 |
| commit | ba523ee94e44fe2ce9e4eee90ffd63eda5a705ae (patch) | |
| tree | 86e09ca1ffcc6c37d2338f5d8d9b1fd84c32dfe3 | |
| parent | d425358bd0ac54bf9bfe176d5328b2d87fa86f27 (diff) | |
add short flags for rest of the flags and print usage when no flags are present
| -rw-r--r-- | main.go | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -19,13 +19,13 @@ func main() { | |||
| 19 | 19 | ||
| 20 | code := getopt.StringLong("code", 'c', "", "Code to enter") | 20 | code := getopt.StringLong("code", 'c', "", "Code to enter") |
| 21 | course := getopt.IntLong("course", 'C', -1, "Canvas course number") | 21 | course := getopt.IntLong("course", 'C', -1, "Canvas course number") |
| 22 | list_all := getopt.BoolLong("list-all", 0, "List all courses") | 22 | list_all := getopt.BoolLong("list-all", 'L', "List all courses") |
| 23 | list_favorites := getopt.BoolLong("list-favorites", 0, "List favorite courses") | 23 | list_favorites := getopt.BoolLong("list-favorites", 'F', "List favorite courses") |
| 24 | help := getopt.BoolLong("help", 0, "Help") | 24 | help := getopt.BoolLong("help", 'h', "Help") |
| 25 | 25 | ||
| 26 | getopt.Parse() | 26 | getopt.Parse() |
| 27 | 27 | ||
| 28 | if *help { | 28 | if *help || (*list_all == false && *list_favorites == false && *code == "" && *course == -1) { |
| 29 | getopt.Usage() | 29 | getopt.Usage() |
| 30 | os.Exit(0) | 30 | os.Exit(0) |
| 31 | } | 31 | } |
