Skip to content

Commit

Permalink
Have the login command honor the --no-input flag (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Jan 24, 2022
1 parent 9063df7 commit f89c425
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions internal/cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/auth0/auth0-cli/internal/ansi"
"github.com/auth0/auth0-cli/internal/auth"
"github.com/auth0/auth0-cli/internal/prompt"
"github.com/spf13/cobra"
"github.com/pkg/browser"
"github.com/spf13/cobra"
)

func loginCmd(cli *cli) *cobra.Command {
Expand Down Expand Up @@ -49,12 +49,17 @@ func RunLogin(ctx context.Context, cli *cli, expired bool) (tenant, error) {
}

fmt.Printf("Your Device Confirmation code is: %s\n\n", ansi.Bold(state.UserCode))
cli.renderer.Infof("%s to open the browser to log in or %s to quit...", ansi.Green("Press Enter"), ansi.Red("^C"))
fmt.Scanln()
err = browser.OpenURL(state.VerificationURI)

if err != nil {
cli.renderer.Warnf("Couldn't open the URL, please do it manually: %s.", state.VerificationURI)
if cli.noInput {
cli.renderer.Infof("Open the following URL in a browser: %s\n", ansi.Green(state.VerificationURI))
} else {
cli.renderer.Infof("%s to open the browser to log in or %s to quit...", ansi.Green("Press Enter"), ansi.Red("^C"))
fmt.Scanln()
err = browser.OpenURL(state.VerificationURI)

if err != nil {
cli.renderer.Warnf("Couldn't open the URL, please do it manually: %s.", state.VerificationURI)
}
}

var res auth.Result
Expand Down

0 comments on commit f89c425

Please sign in to comment.