-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (31 loc) · 651 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
package main
import (
"cli-covid-app/client"
"flag"
"fmt"
"os"
)
var (
helpFLag = flag.Bool("help", false, "displays a list of commands")
countryFlag = flag.String("country", "latvia", "name of country for which the data will be collected")
)
func main() {
flag.Parse()
s := client.NewSwitch(*countryFlag)
if *helpFLag || len(os.Args) == 1 {
s.Help()
return
}
if len(os.Args) == 3 && os.Args[2] == "--help" {
if err := s.CommandHelp(); err != nil {
fmt.Printf("cmd arguments error: %v\n", err)
os.Exit(2)
}
return
}
err := s.Switch()
if err != nil {
fmt.Printf("cmd switch error: %v\n", err)
os.Exit(2)
}
}