From 9b889d90b6222e5bb89ccb95ec672a424ac699ad Mon Sep 17 00:00:00 2001 From: Jens Deppe Date: Wed, 25 Nov 2020 07:47:56 -0800 Subject: [PATCH] Report incorrect or missing commands --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 1f94b3b..ef7c2b4 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "os" "bufio" "io" @@ -12,6 +13,11 @@ import ( func main() { flag.Parse() + if len(flag.Args()) < 2 { + fmt.Println("Too few args specified. Supported commands are 'times', 'unique' and 'hang'.") + os.Exit(1) + } + var p core.Progress switch flag.Arg(0) { case "times": @@ -20,10 +26,14 @@ func main() { p = core.NewProgressUniques() case "hang": p = core.NewProgressHangs() + default: + fmt.Printf("Invalid command: '%s'. Supported commands are 'times', 'unique' and 'hang'.\n", flag.Arg(0)) + os.Exit(1) } var line string for i := 1; i < flag.NArg(); i++ { + fmt.Printf("-------- %s --------\n", flag.Arg(i)) progressFile, err := os.Open(flag.Arg(i)) if err != nil { panic(err)