Skip to content

Commit 9b889d9

Browse files
Report incorrect or missing commands
1 parent 7248b3c commit 9b889d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"flag"
5+
"fmt"
56
"os"
67
"bufio"
78
"io"
@@ -12,6 +13,11 @@ import (
1213
func main() {
1314
flag.Parse()
1415

16+
if len(flag.Args()) < 2 {
17+
fmt.Println("Too few args specified. Supported commands are 'times', 'unique' and 'hang'.")
18+
os.Exit(1)
19+
}
20+
1521
var p core.Progress
1622
switch flag.Arg(0) {
1723
case "times":
@@ -20,10 +26,14 @@ func main() {
2026
p = core.NewProgressUniques()
2127
case "hang":
2228
p = core.NewProgressHangs()
29+
default:
30+
fmt.Printf("Invalid command: '%s'. Supported commands are 'times', 'unique' and 'hang'.\n", flag.Arg(0))
31+
os.Exit(1)
2332
}
2433

2534
var line string
2635
for i := 1; i < flag.NArg(); i++ {
36+
fmt.Printf("-------- %s --------\n", flag.Arg(i))
2737
progressFile, err := os.Open(flag.Arg(i))
2838
if err != nil {
2939
panic(err)

0 commit comments

Comments
 (0)