Skip to content

feat: Login via CLI #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Feb 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move setting browser.Stderr/Stdout to init
  • Loading branch information
bryphe-coder committed Feb 17, 2022
commit dccb009ef3fa53c76ca7ac2f6fb3cfb9a0039897
15 changes: 10 additions & 5 deletions cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ const (
goosDarwin = "darwin"
)

func init() {
// Hide output from the browser library,
// otherwise we can get really verbose and non-actionable messages
// when in SSH or another type of headless session
// NOTE: This needs to be in `init` to prevent data races
// (multiple threads trying to set the global browser.Std* variables)
browser.Stderr = ioutil.Discard
browser.Stdout = ioutil.Discard
}

func login() *cobra.Command {
return &cobra.Command{
Use: "login <url>",
Expand Down Expand Up @@ -223,10 +233,5 @@ func openURL(urlToOpen string) error {
return exec.Command(cmd, args...).Start()
}

// Hide output from the browser library,
// otherwise we can get really verbose and non-actionable messages
// when in SSH or another type of headless session
browser.Stderr = ioutil.Discard
browser.Stdout = ioutil.Discard
return browser.OpenURL(urlToOpen)
}