Skip to content

Commit

Permalink
Merge pull request #75 from 99designs/optional-stdout
Browse files Browse the repository at this point in the history
Stdout parameter to not open login URL in default browser
  • Loading branch information
porty authored Aug 4, 2016
2 parents ed6a70c + 1d5c328 commit 1b8fa98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion login.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type LoginCommandInput struct {
Keyring keyring.Keyring
MfaToken string
MfaPrompt prompt.PromptFunc
UseStdout bool
}

func LoginCommand(ui Ui, input LoginCommandInput) {
Expand Down Expand Up @@ -89,7 +90,9 @@ func LoginCommand(ui Ui, input LoginCommandInput) {
url.QueryEscape(signinToken),
)

if err = open.Run(loginUrl); err != nil {
if input.UseStdout {
fmt.Println(loginUrl)
} else if err = open.Run(loginUrl); err != nil {
log.Println(err)
fmt.Println(loginUrl)
}
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func main() {
login = kingpin.Command("login", "Generate a login link for the AWS Console")
loginProfile = login.Arg("profile", "Name of the profile").Required().String()
loginMfaToken = login.Flag("mfa-token", "The mfa token to use").Short('t').String()
useStdout = login.Flag("stdout", "Print login URL to stdout instead of opening in default browser").Short('s').Bool()
server = kingpin.Command("server", "Run an ec2 instance role server locally")
)

Expand Down Expand Up @@ -131,6 +132,7 @@ func main() {
Keyring: keyring,
MfaToken: *loginMfaToken,
MfaPrompt: prompt.Method(*promptDriver),
UseStdout: *useStdout,
})

case server.FullCommand():
Expand Down

0 comments on commit 1b8fa98

Please sign in to comment.