-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (36 loc) · 938 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"flag"
"fmt"
"time"
"example.com/drs/internal/helpers"
)
func main() {
yearFlag := flag.Int("year", time.Now().Year(), "race year")
raceFlag := flag.Int("race", 0, "race data flag")
driversChampionshipFlag := flag.Bool("drivers", false, "drvier's championship for given year")
constructorsChampionshipFlag := flag.Bool("constructors", false, "constructor's championship for given year")
helpFlag := flag.Bool("help", false, "show help")
flag.Parse()
if flag.NFlag() == 0 {
fmt.Printf("Welcome to DRS!\nUsage:")
helpers.Help() // Call Help function to show the usage
return
}
if *helpFlag {
helpers.Help()
return
}
if *raceFlag != 0 {
helpers.Race(*yearFlag, *raceFlag)
}
if *driversChampionshipFlag {
helpers.DriverStandings(*yearFlag)
fmt.Printf("\n")
}
fmt.Printf("\n")
if *constructorsChampionshipFlag {
helpers.ConstructorStandings(*yearFlag)
fmt.Printf("\n")
}
}