-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgobzl.go
73 lines (55 loc) · 1.61 KB
/
gobzl.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
package main
import (
"context"
"flag"
"os"
"github.com/google/subcommands"
)
type instancesCommand struct {
region string
}
func (*instancesCommand) Name() string {
return "instances"
}
func (*instancesCommand) Synopsis() string {
return "List EC2 instances."
}
func (*instancesCommand) Usage() string {
return "instances [-region <aws-region-name>]"
}
func (c *instancesCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&c.region, "region", "eu-west-1", "AWS region name")
}
func (c *instancesCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
ListEc2Instances(c.region)
return subcommands.ExitSuccess
}
type rdsInstancesCommand struct {
region string
}
func (*rdsInstancesCommand) Name() string {
return "rds-instances"
}
func (*rdsInstancesCommand) Synopsis() string {
return "List RDS DB instances."
}
func (*rdsInstancesCommand) Usage() string {
return "rds-instances [-region <aws-region-name>]"
}
func (c *rdsInstancesCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&c.region, "region", "eu-west-1", "AWS region name")
}
func (c *rdsInstancesCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
ListRdsInstances(c.region)
return subcommands.ExitSuccess
}
func main() {
subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.FlagsCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(&instancesCommand{}, "")
subcommands.Register(&rdsInstancesCommand{}, "")
flag.Parse()
ctx := context.Background()
os.Exit(int(subcommands.Execute(ctx)))
}