-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
130 lines (116 loc) · 2.71 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
125
126
127
128
129
130
package main
import (
"os"
"github.com/mhelmetag/gosurf/cmd"
"github.com/urfave/cli/v2"
)
const VERSION = "3.1.1"
func main() {
var srID string
var d int
var sID string
var tID string
var md int
var t string
app := &cli.App{
Name: "gosurf",
Usage: "is there surf?",
Version: VERSION,
Commands: []*cli.Command{
{
Name: "forecast",
Aliases: []string{"f"},
Usage: "get a forecast for a subregion",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "subregion",
Aliases: []string{"r"},
Required: true,
Usage: "subregion ID",
Destination: &srID,
},
&cli.IntFlag{
Name: "days",
Aliases: []string{"d"},
Value: 3,
Usage: "number of days to report (between 1 and 6)",
Destination: &d,
},
},
Action: func(c *cli.Context) error {
cmd.Forecast(srID, d)
return nil
},
},
{
Name: "tide",
Aliases: []string{"t"},
Usage: "get a tide for a spot",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "spot",
Aliases: []string{"s"},
Required: true,
Usage: "spot ID",
Destination: &sID,
},
&cli.IntFlag{
Name: "days",
Aliases: []string{"d"},
Value: 3,
Usage: "number of days to report (between 1 and 6)",
Destination: &d,
},
},
Action: func(c *cli.Context) error {
cmd.Tide(sID, d)
return nil
},
},
{
Name: "search",
Aliases: []string{"s"},
Usage: "search through the taxonomy tree",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "taxonomy",
Aliases: []string{"t"},
Value: "58f7ed51dadb30820bb38782", // default is Earth
Usage: "taxonomy ID",
Destination: &tID,
},
&cli.IntFlag{
Name: "maxdepth",
Aliases: []string{"d"},
Value: 0, // default to depth 0 for most searches
Usage: "max depth for the tree search",
Destination: &md,
},
},
Action: func(c *cli.Context) error {
cmd.Search(tID, md)
return nil
},
},
{
Name: "search-interactive",
Aliases: []string{"si"},
Usage: "search through the taxonomy tree interactively",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "type",
Aliases: []string{"t"},
Value: "subregion", //
Usage: "mimics tree structure of the 'Cams & Reports' (spots) and 'Forecasts' (subregions) searches",
Destination: &t,
},
},
Action: func(c *cli.Context) error {
cmd.SearchInteractive(t)
return nil
},
},
},
}
app.Run(os.Args)
}