Skip to content
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

Improve headless login #737

Merged
merged 4 commits into from
Dec 14, 2023
Merged

Improve headless login #737

merged 4 commits into from
Dec 14, 2023

Conversation

penberg
Copy link
Contributor

@penberg penberg commented Dec 13, 2023

Fixes #736

When you run `turso auth login` over ssh, for example, OpenURL() will
fail, but in the process it will spam the terminal with the following
useless error logs:

```
/usr/bin/xdg-open: line 881: www-browser: command not found
/usr/bin/xdg-open: line 881: links2: command not found
/usr/bin/xdg-open: line 881: elinks: command not found
/usr/bin/xdg-open: line 881: links: command not found
/usr/bin/xdg-open: line 881: lynx: command not found
/usr/bin/xdg-open: line 881: w3m: command not found
xdg-open: no method available for opening 'https://api.turso.io?port=33609&redirect=true'
```

Hide that to improve the developer experience.
If I am in headless mode, there I can't visit an URL on *this* device so
improve the help text a bit.
If we run `turso auth login`, let's fail more gracefully if we fail to
open the browser.

Without this change, you'll see:

```
$ turso auth login
error: Unable to open browser.
Visit this URL on this device to log in:
https://api.turso.io?port=39935&redirect=true
Waiting for authentication...
```

With the change, it's now:

```
$ turso auth login
Error: failed to open browser, please use the `--headless` command line option.
```
internal/cmd/auth.go Outdated Show resolved Hide resolved
Co-authored-by: Avinash Sajjanshetty <640792+avinassh@users.noreply.github.com>
@penberg penberg merged commit 5f6edd8 into main Dec 14, 2023
2 checks passed
@penberg penberg deleted the improve-headless-login branch December 14, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Headless login experience still sucks
2 participants