Skip to content

Commit

Permalink
call os.Exit(2) in case the parameter for -n is negative.
Browse files Browse the repository at this point in the history
  • Loading branch information
pankona committed Aug 15, 2015
1 parent 7036af5 commit a52a5ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"github.com/PuerkitoBio/goquery"
"os"
"regexp"
"strconv"
"time"
Expand Down Expand Up @@ -90,6 +91,11 @@ func main() {
flag.IntVar(&numOfResult, "n", DefaultNumOfResultToShow, "specify amount of result.")
flag.Parse()

if numOfResult < 0 {
fmt.Fprintf(os.Stderr, "parameter for -n must be greater than 0.\n")
os.Exit(2)
}

hour, minute := departureTime(departure)
timetable := createTimetable(getSelector())

Expand Down

0 comments on commit a52a5ca

Please sign in to comment.