forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
37 lines (30 loc) · 668 Bytes
/
utils.go
File metadata and controls
37 lines (30 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package utils
import (
"fmt"
"os"
"golang.org/x/term"
)
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
}
}
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)
}