-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
146 lines (141 loc) · 3.44 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package main
import (
"log"
"os"
"github.com/HydrologicEngineeringCenter/shape-sql-loader/internal/core"
"github.com/HydrologicEngineeringCenter/shape-sql-loader/internal/global"
"github.com/HydrologicEngineeringCenter/shape-sql-loader/internal/types"
"github.com/urfave/cli/v2"
)
// main entry point into app containing an args parser wrapper
func main() {
app := &cli.App{
Name: global.APP_NAME,
Version: global.APP_VERSION,
Usage: "Upload ESRI shapefiles to PostGIS database",
Commands: []*cli.Command{
{
Name: "prepare",
Usage: "Prepare an modifiable metadata template",
Action: func(c *cli.Context) error {
err := core.Core(c, types.Prep)
return err
},
Flags: []cli.Flag{
&cli.PathFlag{
Name: "shpPath",
Aliases: []string{"s"},
Usage: "Path to shp file",
Required: true,
},
},
},
{
Name: "mod",
Usage: "Options to modify data",
Subcommands: []*cli.Command{
{
Name: "inventory",
Usage: "Upload shp file to PostGIS",
Action: func(c *cli.Context) error {
err := core.Core(c, types.Upload)
return err
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "sqlConn",
Aliases: []string{"s"},
Usage: "PostGIS connection string",
Required: true,
},
&cli.PathFlag{
Name: "xlsPath",
Aliases: []string{"x"},
Usage: "Path to metadata xlsx file",
Required: true,
},
&cli.PathFlag{
Name: "shpPath",
Aliases: []string{"p"},
Usage: "Path to shp file",
Required: true,
},
},
},
{
Name: "user",
Usage: "Add user and their role to group",
Action: func(c *cli.Context) error {
err := core.Core(c, types.Access)
return err
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "sqlConn",
Aliases: []string{"s"},
Usage: "PostGIS connection string",
Required: true,
},
&cli.StringFlag{
Name: "user",
Aliases: []string{"u"},
Usage: "user id",
Required: true,
},
&cli.StringFlag{
Name: "group",
Aliases: []string{"g"},
Usage: "group name",
Required: true,
},
&cli.StringFlag{
Name: "role",
Aliases: []string{"r"},
Usage: "admin / owner / user",
Required: true,
},
},
},
{
Name: "elevation",
Usage: "Add elevation data to inventory table",
Action: func(c *cli.Context) error {
err := core.Core(c, types.Elevation)
return err
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "dataset",
Aliases: []string{"d"},
Usage: "Dataset name",
Required: true,
},
&cli.StringFlag{
Name: "version",
Aliases: []string{"v"},
Usage: "Dataset version",
Required: true,
},
&cli.StringFlag{
Name: "quality",
Aliases: []string{"q"},
Usage: "Dataset quality",
Required: true,
},
&cli.StringFlag{
Name: "sqlConn",
Aliases: []string{"s"},
Usage: "PostGIS connection string",
Required: true,
},
},
},
},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}