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

better errors for gh when not logged in #19

Open
1 of 2 tasks
amtoine opened this issue May 6, 2023 · 2 comments
Open
1 of 2 tasks

better errors for gh when not logged in #19

amtoine opened this issue May 6, 2023 · 2 comments
Labels
enhancement New feature or request sugar Related to the `nu-git-manager-sugar` module

Comments

@amtoine
Copy link
Owner

amtoine commented May 6, 2023

right now, the error is not that great when running gh ... being logged out 🤔
and it does not fail in the sense that the LAST_EXIT_CODE is not set to 1 in that case 🤔

an idea that looks to be working: add gh auth status at the start

remaining things: what happens when the user is

@melMass
Copy link
Collaborator

melMass commented May 6, 2023

right now, the error is not that great when running gh ... being logged out 🤔 and it does not fail in the sense that the LAST_EXIT_CODE is not set to 1 in that case 🤔

Ah, rrrhh so many are not following proper exit codes, your option sound like a good one although the command isn't the fastest (at least when logged)

  • logged out: fails with You are not logged into any GitHub hosts. Run gh auth login to authenticate.

I would output the same error verbatim, probably prefix with some "Host Error" or something similar

  • logged in: ??? => --logged-out option to query the API with http get

I'm not familiar with this flow can you elaborate?

@amtoine
Copy link
Owner Author

amtoine commented May 7, 2023

Ah, rrrhh so many are not following proper exit codes, your option sound like a good one although the command isn't the fastest (at least when logged)

yeah, gh auth status takes a bit of time, it's true 🤔
it's the only thing i've found so far 😕

I would output the same error verbatim, probably prefix with some "Host Error" or something similar

👍

I'm not familiar with this flow can you elaborate?

instead of using gh, you call poll the REST API of GitHub directly 😏
see this gist for instance 😋

amtoine added a commit that referenced this issue May 7, 2023
related to #19 

this PR adds a new `check-gh-logged-in` command to `gh`.
this command checks `gh auth status`, which will return a non-zero exit
code and an error message when not logged in. Then, `check-gh-logged-in`
will return a nice `nushell` unspanned error.

the error is
```
Error: 
  × You are not logged into any GitHub hosts. Run gh auth login to
  │ authenticate.
  │ 
```
otherwise, when already logged in, nothing is shown at all and the
scripts work as expected

> **Note**
> the slow down is quite small and hard to see, i think it's ok to have
such a better error handling 😌
@amtoine amtoine added the enhancement New feature or request label Oct 11, 2023
@amtoine amtoine added the sugar Related to the `nu-git-manager-sugar` module label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sugar Related to the `nu-git-manager-sugar` module
Projects
None yet
Development

No branches or pull requests

2 participants