-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (43 loc) · 1.11 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
package main
import (
"fmt"
"os"
"github.com/grimdork/opt"
)
var o struct {
opt.DefaultHelp
List ListCmd `command:"list" help:"List keys." aliases:"ls"`
Get GetCmd `command:"get" help:"Get value(s) for a key." aliases:"g"`
Set SetCmd `command:"set" help:"Set the value for a key." aliases:"s"`
Tag TagCmd `command:"tag" help:"Add tags to a key." aliases:"t"`
Rename RenameCmd `command:"rename" help:"Rename key." aliases:"ren,r"`
Remove RemoveCmd `command:"remove" help:"Remove key." aliases:"rm"`
// Backup BackupCmd `command:"backup" help:"Back up all keys to S3." aliases:"bak"`
Version VersionCmd `command:"version" help:"Show version information." aliases:"ver,v"`
}
var (
version = "dev"
date = "undefined"
)
func init() {
os.Setenv("AWS_SDK_LOAD_CONFIG", "true")
}
func main() {
a := opt.Parse(&o)
if o.Help {
a.Usage()
return
}
err := a.RunCommand(false)
if err != nil {
if err == opt.ErrNoCommand {
a.Usage()
return
}
pr("Error running command: %s", err.Error())
os.Exit(2)
}
}
func pr(format string, v ...interface{}) {
fmt.Printf(format+"\n", v...)
}