-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (28 loc) · 997 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
package main
import (
"os"
"gopkg.in/alecthomas/kingpin.v2"
"github.com/rdooley/confidynt/cli"
"github.com/rdooley/confidynt/service"
)
var (
app = kingpin.New("confidynt", "A command-line application for 12 factor config dynamo db management")
dryrun = app.Flag("dryrun", "Enable dryrun mode.").Bool()
table = app.Flag("table", "Table name").Required().String()
read = app.Command("read", "Read a config from dynamo")
readKey = read.Arg("key", "Query key").Required().String()
readValue = read.Arg("value", "Query value").Required().String()
write = app.Command("write", "Write a config file to dynamo")
writeFile = write.Arg("config", "Config file to write").ExistingFile()
dynamo = service.NewDynamo()
)
func main() {
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
// Read
case read.FullCommand():
cli.Read(*table, *readKey, *readValue, dynamo, os.Stdout)
// Write
case write.FullCommand():
cli.Write(*table, *writeFile, dynamo, os.Stdout)
}
}