Add documentation comments to exported symbols across all remaining smaller packages including cmd/gen-docs, context, internal/browser, internal/gh, internal/ghcmd, internal/ghinstance, internal/ghrepo, internal/keyring, internal/run, internal/safepaths, internal/tableprinter, internal/text, internal/update, pkg/cmd/accessibility, pkg/cmd/actions, pkg/cmd/alias, pkg/cmd/api, pkg/cmd/browse, pkg/cmd/cache, pkg/cmd/completion, pkg/cmd/copilot, pkg/cmd/factory, pkg/cmd/gpg-key, pkg/cmd/label, pkg/cmd/licenses, pkg/cmd/org, pkg/cmd/preview, pkg/cmd/ssh-key, pkg/cmd/version, pkg/extensions, pkg/jsoncolor, pkg/markdown, pkg/option, pkg/set, pkg/ssh, pkg/surveyext, test, internal/authflow, and utils. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
39 lines
786 B
Go
39 lines
786 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
// IsDebugEnabled reports whether debug mode is active.
|
|
func IsDebugEnabled() (bool, string) {
|
|
debugValue, isDebugSet := os.LookupEnv("GH_DEBUG")
|
|
legacyDebugValue := os.Getenv("DEBUG")
|
|
|
|
if !isDebugSet {
|
|
switch legacyDebugValue {
|
|
case "true", "1", "yes", "api":
|
|
return true, legacyDebugValue
|
|
default:
|
|
return false, legacyDebugValue
|
|
}
|
|
}
|
|
|
|
switch debugValue {
|
|
case "false", "0", "no", "":
|
|
return false, debugValue
|
|
default:
|
|
return true, debugValue
|
|
}
|
|
}
|
|
|
|
// TerminalSize returns the width and height of the terminal.
|
|
var TerminalSize = func(w interface{}) (int, int, error) {
|
|
if f, isFile := w.(*os.File); isFile {
|
|
return term.GetSize(int(f.Fd()))
|
|
}
|
|
|
|
return 0, 0, fmt.Errorf("%v is not a file", w)
|
|
}
|