summaryrefslogtreecommitdiffstats
path: root/internal/formatter/formatter.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/formatter/formatter.go')
-rw-r--r--internal/formatter/formatter.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/internal/formatter/formatter.go b/internal/formatter/formatter.go
index 4d65c60..bb36fa8 100644
--- a/internal/formatter/formatter.go
+++ b/internal/formatter/formatter.go
@@ -10,6 +10,7 @@ import (
"text/tabwriter"
"git.db.org.ai/dborg/internal/utils"
+ "golang.org/x/term"
)
const (
@@ -71,7 +72,14 @@ func isTerminal() bool {
}
func GetTerminalWidth() int {
- return 80
+ if !isTerminal() {
+ return 80
+ }
+ width, _, err := term.GetSize(int(os.Stdout.Fd()))
+ if err != nil || width <= 0 {
+ return 80
+ }
+ return width
}
func Colorize(text string, color string) string {
@@ -323,10 +331,11 @@ func PrintSection(title string) {
}
func PrintDivider() {
+ width := GetTerminalWidth()
if isTerminal() {
- fmt.Println(Dim(strings.Repeat("─", 80)))
+ fmt.Println(Dim(strings.Repeat("─", width)))
} else {
- fmt.Println(strings.Repeat("-", 80))
+ fmt.Println(strings.Repeat("-", width))
}
}