diff --git a/cmd/awscli.go b/cmd/awscli.go index 860010d..27d4951 100644 --- a/cmd/awscli.go +++ b/cmd/awscli.go @@ -1,8 +1,11 @@ package cmd import ( + "os" + log "github.com/Sirupsen/logrus" "github.com/lmhd/lucli/creds" + "github.com/lmhd/lucli/lib" "github.com/skybet/cali" ) @@ -12,6 +15,10 @@ func init() { command := cli.NewCommand("awscli [command]") command.SetShort("AWS CLI / Shell") + // Allow this command to be run with awsshell too + // Dunno. Might made this a top tier command instead, so it shows in help. + command.SetAliases([]string{"awsshell"}) + // TODO: long description // Include AWS CLI/Shell // Mention JQ is included @@ -22,9 +29,9 @@ func init() { task := command.Task("lucymhdavies/awscli:latest") task.SetInitFunc(func(t *cali.Task, args []string) { - // TODO: detect if ran with awsshell alias? - if cli.FlagValues().GetBool("shell") { + // if awscli -s, or awsshell + if cli.FlagValues().GetBool("shell") || lib.StringSliceContains(os.Args, "awsshell") { log.Debugf("Using AWS Shell") // TODO: cali DockerClient.SetEntrypoint diff --git a/lib/util.go b/lib/util.go new file mode 100644 index 0000000..8fe6884 --- /dev/null +++ b/lib/util.go @@ -0,0 +1,12 @@ +package lib + +// Random useful stuff. + +func StringSliceContains(s []string, e string) bool { + for _, a := range s { + if a == e { + return true + } + } + return false +}