forked from bradw2k/form5500-data-sets-import
-
Notifications
You must be signed in to change notification settings - Fork 1
/
form5500.go
54 lines (40 loc) · 1.67 KB
/
form5500.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
package main
import (
"flag"
"fmt"
"strings"
utils "github.com/jdcalvin/form5500/internal/utils"
)
var hostFlag = flag.String("host", "localhost", "connection host")
var portFlag = flag.String("port", "5432", "connection port")
var userFlag = flag.String("user", "", "username (optional)")
var passwordFlag = flag.String("password", "", "password (optional)")
var dbFlag = flag.String("db", "", "specify existing database to store data")
var sslFlag = flag.String("ssl", "disable", "connection sslmode: require, verify-full, verify-ca, disable")
var yearsFlag = flag.String("years", "", "Specify form5500 year")
var sectionFlag = flag.String("section", "", "Specify form5500 section ('all' or 'latest')")
var isImportFlag = flag.Bool("import", false, "Download csvs into database")
var isBuildFlag = flag.Bool("build", false, "Builds form5500_search table from all long form and short form form5500 tables")
var isExtensionFlag = flag.String("extension", "", "Add extensions to ")
func main() {
flag.Parse()
form5500Flag := new(utils.Form5500Flags)
if (!*isImportFlag && !*isBuildFlag && (*isExtensionFlag == "")) {
fmt.Println("Must specify import, build, or an extension")
}
form5500Flag.Section = *sectionFlag
form5500Flag.Years = strings.Split(*yearsFlag, ",")
form5500Flag.SetConnection(*hostFlag, *portFlag, *dbFlag, *sslFlag, *userFlag, *passwordFlag)
utils.SetDBConnection(form5500Flag.Connection)
utils.OpenDBConnection()
defer utils.CloseDBConnection()
if *isImportFlag {
runImport(form5500Flag.Section, form5500Flag.Years)
}
if *isBuildFlag {
buildTable(form5500Flag.Section, form5500Flag.Years)
}
if *isExtensionFlag != "" {
callExtension(*isExtensionFlag)
}
}