Example #1
0
func main() {
	app := cli.NewApp()
	app.Name = "envaws"
	app.Version = "0.1.0dev"
	app.Usage = `AWS access key manager
	    Help you to export environment variables and unset them easily.

   e.g)
     To export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for default profile

        $ eval $(envaws env default)

     To unset them

        $ eval $(envaws unset)`
	app.Commands = []cli.Command{
		cli.Command{
			Name:  "ls",
			Usage: "List available profiles in ~/.aws/credentials",
			Flags: []cli.Flag{},
			Action: func(ctx *cli.Context) {
				listProfiles()
			},
		},
		cli.Command{
			Name:  "env",
			Usage: "Print keys as environtment variables for profile",
			Args:  "<profile>",
			Flags: []cli.Flag{},
			Action: func(ctx *cli.Context) {
				profile, _ := ctx.ArgFor("profile")
				sec := loadParams(profile)
				formatEnv(sec, ctx.String("format"))
			},
		},
		cli.Command{
			Name:  "unset",
			Usage: "Print commands to unset environtment variables for AWS_*",
			Action: func(ctx *cli.Context) {
				unset()
			},
		},
		cli.Command{
			Name:  "tf",
			Args:  "<profile>",
			Usage: "Print keys as terraform variable definition for profile",
			Flags: []cli.Flag{
				cli.StringFlag{Name: "format,f", Value: "var", Usage: "option,env,var,export"},
			},
			Action: func(ctx *cli.Context) {
				profile, _ := ctx.ArgFor("profile")
				sec := loadParams(profile)
				formatTf(sec, ctx.String("format"))
			},
		},
	}
	app.Run(os.Args)
}
Example #2
0
func main() {
	app := cli.NewApp()
	app.Name = "kii-cli"
	app.Usage = "KiiCloud command line interface"
	app.Version = "0.1.7"
	app.Commands = []cli.Command{
		cli.Command{
			Name:        "auth",
			Usage:       "Authentication",
			Subcommands: kiicli.LoginCommands,
		},
		cli.Command{
			Name:        "app",
			Usage:       "Application management",
			Subcommands: kiicli.AppCommands,
		},
		kiicli.LogCommands[0],
		cli.Command{
			Name:        "servercode",
			Usage:       "Server code management",
			Subcommands: kiicli.ServerCodeCommands,
		},
		cli.Command{
			Name:        "user",
			Usage:       "User management",
			Subcommands: kiicli.UserCommands,
		},
		cli.Command{
			Name:        "bucket",
			Usage:       "Bucket management",
			Subcommands: kiicli.BucketCommands,
		},
		cli.Command{
			Name:        "object",
			Usage:       "Object management",
			Subcommands: kiicli.ObjectCommands,
		},
		cli.Command{
			Name:        "dev",
			Usage:       "Development support",
			Subcommands: kiicli.WSEchoCommands,
		},
		cli.Command{
			Name:        "profile",
			Usage:       "Profile management",
			Subcommands: kiicli.ProfileCommands,
		},
	}
	if os.Getenv("FLAT") != "" {
		app.Commands = kiicli.Flatten(app.Commands)
	}
	kiicli.SetupFlags(app)
	app.Run(os.Args)
}