Documentation
¶
Index ¶
- Variables
- type Color
- type Logger
- func (l *Logger) Errf(color Color, s string, args ...any)
- func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...any)
- func (l *Logger) Outf(color Color, s string, args ...any)
- func (l *Logger) PrintExperiments() error
- func (l *Logger) Prompt(color Color, prompt string, defaultValue string, continueValues ...string) error
- func (l *Logger) UnstampedErrf(color Color, s string, args ...any)
- func (l *Logger) UnstampedOutf(color Color, s string, args ...any)
- func (l *Logger) UnstampedStderr() io.Writer
- func (l *Logger) UnstampedStdout() io.Writer
- func (l *Logger) VerboseErrf(color Color, s string, args ...any)
- func (l *Logger) VerboseOutf(color Color, s string, args ...any)
- func (l *Logger) Warnf(message string, args ...any)
- type PrintFunc
- func Blue() PrintFunc
- func BrightBlue() PrintFunc
- func BrightCyan() PrintFunc
- func BrightGreen() PrintFunc
- func BrightMagenta() PrintFunc
- func BrightRed() PrintFunc
- func BrightYellow() PrintFunc
- func Cyan() PrintFunc
- func Default() PrintFunc
- func Green() PrintFunc
- func Magenta() PrintFunc
- func None() PrintFunc
- func Red() PrintFunc
- func Yellow() PrintFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrPromptCancelled = errors.New("prompt cancelled") ErrNoTerminal = errors.New("no terminal") )
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
RawStdout io.Writer
RawStderr io.Writer
Verbose bool
Color bool
AssumeYes bool
AssumeTerm bool // Used for testing
}
Logger is just a wrapper that prints stuff to STDOUT or STDERR, with optional color.
Stdout / Stderr are the "rite logger" sinks: when global timestamps are on (CLI `--timestamps` or top-level `timestamps:`), these are wrapped with a TimestampWriter by setupTimestamps(), so every Outf / Errf line comes out stamped.
RawStdout / RawStderr are the un-stamped writers the Logger was born with. They point at the Executor's original Stdout / Stderr (usually os.Stdout / os.Stderr or a test buffer) regardless of global-timestamp state. CLI-meta output — task lists, task summaries, the `--help` text, `--version`, etc. — should write through these, not through Stdout / Stderr. A timestamp on `rite -l` or `rite --summary foo` treats the listing itself as task-execution output, which it isn't — the listing is metadata *about* the Ritefile, on the same conceptual tier as `--help`.
If RawStdout / RawStderr are left nil (e.g. a caller that constructs a Logger directly and bypasses setupTimestamps), UnstampedOutf / Errf fall back to Stdout / Stderr so no call site has to nil-check.
func (*Logger) PrintExperiments ¶
func (*Logger) UnstampedErrf ¶ added in v1.0.8
UnstampedErrf mirrors UnstampedOutf on stderr.
func (*Logger) UnstampedOutf ¶ added in v1.0.8
UnstampedOutf prints to the un-stamped stdout writer — i.e. the writer that bypasses the global TimestampWriter wrap applied by setupTimestamps. Use this for CLI-meta output (task lists, summaries, help text) that is not task-execution output and therefore shouldn't carry run-time timestamps even under top-level `timestamps: true`.
func (*Logger) UnstampedStderr ¶ added in v1.0.8
UnstampedStderr mirrors UnstampedStdout on stderr.
func (*Logger) UnstampedStdout ¶ added in v1.0.8
UnstampedStdout returns the un-stamped stdout writer so callers that need to pass a writer to external helpers (tabwriter, json encoder, etc.) can route bytes around the TimestampWriter.
func (*Logger) VerboseErrf ¶
VerboseErrf prints stuff to STDERR if verbose mode is enabled.
func (*Logger) VerboseOutf ¶
VerboseOutf prints stuff to STDOUT if verbose mode is enabled.
type PrintFunc ¶
func BrightBlue ¶
func BrightBlue() PrintFunc
func BrightCyan ¶
func BrightCyan() PrintFunc
func BrightGreen ¶
func BrightGreen() PrintFunc
func BrightMagenta ¶
func BrightMagenta() PrintFunc
func BrightYellow ¶
func BrightYellow() PrintFunc