cleanup
This commit is contained in:
parent
a79a0bbfd7
commit
414de332fb
4 changed files with 11 additions and 14 deletions
|
|
@ -136,14 +136,11 @@ func main() {
|
|||
|
||||
cs := cmdFactory.IOStreams.ColorScheme()
|
||||
|
||||
// _, _, tokenPresent := config.AuthTokenFromEnv(ghinstance.OverridableDefault())
|
||||
// authCheckEnabled := !tokenPresent && cmd != nil && cmdutil.IsAuthCheckEnabled(cmd)
|
||||
authCheckEnabled := cmd != nil && cmdutil.IsAuthCheckEnabled(cmd)
|
||||
if authCheckEnabled && !cmdutil.CheckAuth(cfg) {
|
||||
if cmd != nil && cmdutil.IsAuthCheckEnabled(cmd) && !cmdutil.CheckAuth(cfg) {
|
||||
fmt.Fprintln(stderr, cs.Bold("Welcome to GitHub CLI!"))
|
||||
fmt.Fprintln(stderr)
|
||||
fmt.Fprintln(stderr, "To authenticate, please run `gh auth login`.")
|
||||
fmt.Fprintln(stderr, "You can also set the one of the oauth token environment variables, if preferred.")
|
||||
fmt.Fprintln(stderr, "You can also set the one of the auth token environment variables, if preferred.")
|
||||
os.Exit(4)
|
||||
}
|
||||
|
||||
|
|
@ -246,8 +243,8 @@ func basicClient(currentVersion string) (*api.Client, error) {
|
|||
}
|
||||
opts = append(opts, api.AddHeader("User-Agent", fmt.Sprintf("GitHub CLI %s", currentVersion)))
|
||||
|
||||
token, _, ok := config.AuthTokenFromEnv(ghinstance.Default())
|
||||
if !ok {
|
||||
token, _, found := config.AuthTokenFromEnv(ghinstance.Default())
|
||||
if !found {
|
||||
if c, err := config.ParseDefaultConfig(); err == nil {
|
||||
token, _ = c.Get(ghinstance.Default(), "oauth_token")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ func (c *envConfig) Get(hostname, key string) (string, error) {
|
|||
|
||||
func (c *envConfig) GetWithSource(hostname, key string) (string, string, error) {
|
||||
if hostname != "" && key == "oauth_token" {
|
||||
if value, name, found := AuthTokenFromEnv(hostname); found {
|
||||
return value, name, nil
|
||||
if token, env, found := AuthTokenFromEnv(hostname); found {
|
||||
return token, env, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,8 +55,8 @@ func (c *envConfig) GetWithSource(hostname, key string) (string, string, error)
|
|||
|
||||
func (c *envConfig) CheckWriteable(hostname, key string) error {
|
||||
if hostname != "" && key == "oauth_token" {
|
||||
if _, name, found := AuthTokenFromEnv(hostname); found {
|
||||
return fmt.Errorf("read-only token in %s cannot be modified", name)
|
||||
if _, env, found := AuthTokenFromEnv(hostname); found {
|
||||
return fmt.Errorf("read-only token in %s cannot be modified", env)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ original query accepts an '$endCursor: String' variable and that it fetches the
|
|||
`),
|
||||
Annotations: map[string]string{
|
||||
"help:environment": heredoc.Doc(`
|
||||
GH_TOKEN, GITHUB_TOKEN (in order of procedence): an authentication token for github.com API requests.
|
||||
GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for github.com API requests.
|
||||
|
||||
GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of procedence): an authentication token for API requests to GitHub Enterprise.
|
||||
GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN (in order of precedence): an authentication token for API requests to GitHub Enterprise.
|
||||
|
||||
GH_HOST: make the request to a GitHub host other than github.com.
|
||||
`),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ var HelpTopics = map[string]map[string]string{
|
|||
"environment": {
|
||||
"short": "Environment variables that can be used with gh",
|
||||
"long": heredoc.Doc(`
|
||||
GH_TOKEN, GITHUB_TOKEN (in order of procedence): an authentication token for github.com
|
||||
GH_TOKEN, GITHUB_TOKEN (in order of precedence): an authentication token for github.com
|
||||
API requests. Setting this avoids being prompted to authenticate and takes precedence over
|
||||
previously stored credentials.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue