forked from toolshed/abra
test: full width for CI testing [ci skip]
Also clean up the .env.sample.
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -42,22 +43,33 @@ func HumanDuration(timestamp int64) string {
|
||||
|
||||
// CreateTable prepares a table layout for output.
|
||||
func CreateTable() (*table.Table, error) {
|
||||
table := table.New().
|
||||
Border(lipgloss.ThickBorder()).
|
||||
BorderStyle(
|
||||
lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("63")),
|
||||
)
|
||||
|
||||
if isAbraCI, ok := os.LookupEnv("ABRA_CI"); ok && isAbraCI == "1" {
|
||||
// NOTE(d1): no width limits for CI testing since we test against outputs
|
||||
log.Debug("detected ABRA_CI=1")
|
||||
return table, nil
|
||||
}
|
||||
|
||||
width, _, err := term.GetSize(0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if width-10 < 79 {
|
||||
width = 79
|
||||
// NOTE(d1): maintain standard minimum width
|
||||
table.Width(79)
|
||||
} else {
|
||||
// NOTE(d1): tests show that this produces stable border drawing
|
||||
table.Width(width - 10)
|
||||
}
|
||||
|
||||
return table.New().
|
||||
Width(width - 10).
|
||||
Border(lipgloss.ThickBorder()).
|
||||
BorderStyle(
|
||||
lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("63")),
|
||||
), nil
|
||||
return table, nil
|
||||
}
|
||||
|
||||
// ToJSON converts a lipgloss.Table to JSON representation. It's not a robust
|
||||
|
Reference in New Issue
Block a user