47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package bonfire
|
|
|
|
import (
|
|
"io"
|
|
|
|
"git.golem15.com/golem15/summercms/internal/consolekit"
|
|
"github.com/charmbracelet/colorprofile"
|
|
)
|
|
|
|
// ColorMode selects how console output decides on color: from the terminal
|
|
// and the environment, always, or never.
|
|
type ColorMode = consolekit.ColorMode
|
|
|
|
const (
|
|
// ColorAuto colors output when the writer is a terminal and the
|
|
// environment allows it (NO_COLOR and TERM=dumb disable color,
|
|
// FORCE_COLOR enables it on any writer).
|
|
ColorAuto = consolekit.ColorAuto
|
|
// ColorAlways colors output whatever the writer is (--ansi).
|
|
ColorAlways = consolekit.ColorAlways
|
|
// ColorNever writes no escape codes at all (--no-ansi).
|
|
ColorNever = consolekit.ColorNever
|
|
)
|
|
|
|
// Palette is the shared console look: the status styles of list, help,
|
|
// widgets and log lines (Success, Current, Warning, Error, ErrorBold, Muted
|
|
// and Header). Render through a writer that applies the color profile
|
|
// (DetectProfile), because lipgloss always emits ANSI codes.
|
|
type Palette = consolekit.Palette
|
|
|
|
// DefaultPalette returns the console palette, ported from SSU's status
|
|
// styles: green success, cyan current, yellow warning, red and bold red
|
|
// errors, gray (240) muted text and bold headers.
|
|
func DefaultPalette() Palette {
|
|
return consolekit.DefaultPalette()
|
|
}
|
|
|
|
// DetectProfile returns the color profile for console output written to w.
|
|
// ColorNever gives colorprofile.NoTTY (no escape codes at all). ColorAlways
|
|
// gives the detected profile raised to at least 256 colors. ColorAuto treats
|
|
// a non-empty FORCE_COLOR as ColorAlways unless NO_COLOR is set or TERM is
|
|
// dumb, and otherwise detects the profile from w and environ, which honours
|
|
// NO_COLOR and TERM=dumb. A nil environ means os.Environ().
|
|
func DetectProfile(w io.Writer, mode ColorMode, environ []string) colorprofile.Profile {
|
|
return consolekit.DetectProfile(w, mode, environ)
|
|
}
|