Use the authenticated user as default user
Hi 👋🏼
Given the GitHub CLI need to be authenticated, there is already a default me user.
So maybe the initial default user prompt can be removed and:
- use the authenticated user as default user
- keep the ability to set a different default user from conf
+1, why do we need to provide username/password upon installation if thats already done via the dh login command?
+1 you already get the output of the gh auth status here
and in that output there is a username:
github.com
✓ Logged in to github.com as Zeviraty (/home/zev/.config/gh/hosts.yml)
✓ Git operations for github.com configured to use ssh protocol.
✓ Token: gho_************************************
✓ Token scopes: admin:public_key, delete_repo, gist, read:org, repo
and you can use this regex to get it:
✓ Logged in to github\.com as ([A-Za-z]+) \([^)]*\)
the resulting first capture group returning the username
Actually, you can directly have this as a JSON-formatted output:
$ gh auth status --json hosts
{
"hosts": {
"github.com": [
{
"state": "success",
"active": true,
"host": "github.com",
"login": "my-username",
"tokenSource": "GH_TOKEN",
"scopes": "...",
"gitProtocol": "ssh"
}
]
}
}
Oh didnt notice that but the one i posted could be helpfull because the command is already executed but if not, that is better
It should not ask for gh authentication on installation with the latest release, however you still need to authenticate after.
@noirbizarre thanks for the tip - I ended up using that approach.