nu-git-manager icon indicating copy to clipboard operation
nu-git-manager copied to clipboard

better errors for `gh` when not logged in

Open amtoine opened this issue 2 years ago • 2 comments

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

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

remaining things: what happens when the user is

  • [x] logged out: fails with You are not logged into any GitHub hosts. Run gh auth login to authenticate.
    • #20
  • [ ] logged in: ??? => --logged-out option to query the API with http get

amtoine avatar May 06 '23 09:05 amtoine

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?

melMass avatar May 06 '23 14:05 melMass

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 :thinking: it's the only thing i've found so far :confused:

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

:+1:

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

instead of using gh, you call poll the REST API of GitHub directly :smirk: see this gist for instance :yum:

amtoine avatar May 07 '23 08:05 amtoine