-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
73 lines (68 loc) · 1.58 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
package main
import (
"fmt"
"github.com/kellyp/lowprofile/Godeps/_workspace/src/github.com/codegangsta/cli"
"github.com/kellyp/lowprofile/lib"
"os"
)
func main() {
app := cli.NewApp()
app.Name = "lowprofile"
app.Usage = "Control AWS profiles"
app.Version = "0.1"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "shall we debug?",
},
}
app.Before = func(c *cli.Context) error {
if c.Bool("debug") {
lowprofile.Debug = true
lowprofile.Debugln("Turning debug on.")
}
return nil
}
app.Commands = []cli.Command{
{
Name: "describe-profiles",
Aliases: []string{"d"},
Usage: `Describes the list of AWS profile`,
Before: lowprofile.BeforeDescribeProfiles,
Action: lowprofile.DescribeProfiles,
},
{
Name: "describe-active-profile",
Aliases: []string{"dap"},
Usage: `Describes the currently active AWS profile`,
Action: lowprofile.DescribeActiveProfile,
},
{
Name: "activate-profile",
Aliases: []string{"ap"},
Usage: `Sets the currently active profile`,
Before: lowprofile.BeforeActivateProfile,
Action: lowprofile.ActivateProfile,
Flags: []cli.Flag{
cli.StringFlag{
Name: "profile",
Usage: "name of the profile to activate",
Value: "profile-name",
},
},
},
{
Name: "deactive-profile",
Aliases: []string{"dp"},
Usage: `Deactivate the currently active AWS profile`,
Before: lowprofile.BeforeDeactivateProfile,
Action: lowprofile.DeactivateProfile,
},
}
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
}
}()
app.Run(os.Args)
}