token accounting cleanup
This commit is contained in:
+20
-2
@@ -2,9 +2,27 @@
|
||||
|
||||
package main
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func termWidth() int { return 80 }
|
||||
func termWidth() int {
|
||||
if w := os.Getenv("COLUMNS"); w != "" {
|
||||
if n, err := strconv.Atoi(strings.TrimSpace(w)); err == nil && n > 0 {
|
||||
return n
|
||||
}
|
||||
}
|
||||
if out, err := exec.Command("tput", "cols").Output(); err == nil {
|
||||
if n, err := strconv.Atoi(strings.TrimSpace(string(out))); err == nil && n > 0 {
|
||||
return n
|
||||
}
|
||||
}
|
||||
return 80
|
||||
}
|
||||
|
||||
func isTerminal(fd int) bool { return false }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user