Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Commit

Permalink
Added command "prompt"
Browse files Browse the repository at this point in the history
  • Loading branch information
Luzifer committed Jun 23, 2015
1 parent 498fa27 commit 98816b5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -124,6 +124,10 @@ AWS_ACCESS_KEY_ID=myaccesskey
AWS_ACCESS_KEY=myaccesskey
AWS_SECRET_KEY=mysecretkey

# Now the prompt command can tell you which env is set
$ awsenv prompt
demoenv

# Lets try to unlock with a wrong password
$ awsenv lock
$ awsenv unlock
Expand Down
25 changes: 25 additions & 0 deletions cmdPrompt.go
@@ -0,0 +1,25 @@
package main

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

func getCmdPrompt() *cobra.Command {
cmd := cobra.Command{
Use: "prompt",
Short: "echos the name of the currently set env for use in prompts",
Run: actionCmdPrompt,
}
return &cmd
}

func actionCmdPrompt(cmd *cobra.Command, args []string) {
for k, v := range awsCredentials.Credentials {
if v.AWSAccessKeyID == os.Getenv("AWS_ACCESS_KEY") {
fmt.Printf(k)
}
}
}
1 change: 1 addition & 0 deletions main.go
Expand Up @@ -94,6 +94,7 @@ func main() {
getCmdList(),
getCmdLock(),
getCmdShell(),
getCmdPrompt(),
getCmdUnlock(),
getCmdVersion(),
)
Expand Down

0 comments on commit 98816b5

Please sign in to comment.