-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
124 lines (106 loc) · 2.45 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package main
import (
"flag"
"fmt"
"time"
"github.com/Luiggy102/south-american-qualifiers-cli/cmd"
"github.com/Luiggy102/south-american-qualifiers-cli/internal/requests"
"github.com/Luiggy102/south-american-qualifiers-cli/types"
)
func main() {
// program flags
// print positions table
printTable := flag.Bool("table", false, "display current table")
// boolean flags
// show next matches
showFixtures := flag.Bool("show-fixture", false, "show next matches")
// show previous matches
showPrevious := flag.Bool("show-previous", false, "show previous matches")
// strings flags
// show team next matches
teamFixture := flag.String("fixture", " ", "show team fixture")
// show team previous matches
teamPrevious := flag.String("previous", " ", "show played matches for a team")
flag.Parse()
// boolean flags
// Print Position table
if *printTable {
var table types.Table = requests.Table()
cmd.PrintTable(table)
apiRequestedInfo()
return
}
// show all fixture
if *showFixtures {
var nextMatches types.NextMatches = requests.NextMatches()
cmd.ShowFixture(nextMatches)
apiRequestedInfo()
return
}
// show all previous matches
if *showPrevious {
var prevMatches types.PreviousMatches = requests.PreviousMatches()
cmd.Played(prevMatches)
apiRequestedInfo()
return
}
// strings flags
var teams = [10]string{
"Argentina",
"Bolivia",
"Brasil",
"Chile",
"Colombia",
"Ecuador",
"Paraguay",
"Perú",
"Uruguay",
"Venezuela",
}
/// next matches
for _, v := range teams {
// Pass
if v != *teamFixture {
continue
}
// check the teams
switch *teamFixture {
case v:
var nextMatches types.NextMatches = requests.NextMatches()
cmd.TeamFixture(v, nextMatches)
apiRequestedInfo()
return
case " ":
//
default:
fmt.Println("Invalid option")
}
}
/// played matches
for _, v := range teams {
// Pass
if v != *teamPrevious {
continue
}
// check the teams
switch *teamPrevious {
case v:
var prevMatches types.PreviousMatches = requests.PreviousMatches()
cmd.ShowPrevious(v, prevMatches)
apiRequestedInfo()
return
case " ":
//
default:
fmt.Println("Invalid option")
}
}
// if none of the flags was used print this message
info := `Welcome to south-american-qualifiers-cli!
type -h or --help for more info`
fmt.Println(info)
}
func apiRequestedInfo() {
fmt.Println("\nApi requested at:")
fmt.Println(time.Now().Format("Monday 01-02-2006 15:04:05"))
}