@@ -58,7 +58,7 @@ func mainRun() exitCode {
5858 updateMessageChan <- rel
5959 }()
6060
61- hasDebug := os . Getenv ( "DEBUG" ) != ""
61+ hasDebug , _ := utils . IsDebugEnabled ()
6262
6363 cmdFactory := factory .New (buildVersion )
6464 stderr := cmdFactory .IOStreams .ErrOut
@@ -327,8 +327,10 @@ func checkForUpdate(currentVersion string) (*update.ReleaseInfo, error) {
327327// does not depend on user configuration
328328func basicClient (currentVersion string ) (* api.Client , error ) {
329329 var opts []api.ClientOption
330- if verbose := os .Getenv ("DEBUG" ); verbose != "" {
331- opts = append (opts , apiVerboseLog ())
330+ if isVerbose , debugValue := utils .IsDebugEnabled (); isVerbose {
331+ colorize := utils .IsTerminal (os .Stderr )
332+ logTraffic := strings .Contains (debugValue , "api" )
333+ opts = append (opts , api .VerboseLog (colorable .NewColorable (os .Stderr ), logTraffic , colorize ))
332334 }
333335 opts = append (opts , api .AddHeader ("User-Agent" , fmt .Sprintf ("GitHub CLI %s" , currentVersion )))
334336
@@ -344,12 +346,6 @@ func basicClient(currentVersion string) (*api.Client, error) {
344346 return api .NewClient (opts ... ), nil
345347}
346348
347- func apiVerboseLog () api.ClientOption {
348- logTraffic := strings .Contains (os .Getenv ("DEBUG" ), "api" )
349- colorize := utils .IsTerminal (os .Stderr )
350- return api .VerboseLog (colorable .NewColorable (os .Stderr ), logTraffic , colorize )
351- }
352-
353349func isRecentRelease (publishedAt time.Time ) bool {
354350 return ! publishedAt .IsZero () && time .Since (publishedAt ) < time .Hour * 24
355351}
0 commit comments