Documentation
¶
Index ¶
- Constants
- func Env(desc, envVar string) string
- func PromptPassword(prompt string) (string, error)
- type ConsoleReporter
- type NoOpReporter
- type Phase
- type Reporter
- type SafeLogWriter
- type TermWriter
- func (t TermWriter) Blank()
- func (t TermWriter) Command(name, args string)
- func (t TermWriter) Commands(cmds [][2]string)
- func (t TermWriter) Examples(cmds ...string)
- func (t TermWriter) Flags(flags [][2]string)
- func (t TermWriter) Heading(title string)
- func (t TermWriter) HeadingSub(title, subtitle string)
- func (t TermWriter) Note(lines ...string)
Constants ¶
const ( Bold = logger.ColorBold Dim = logger.ColorDim Cyan = logger.ColorCyan Green = logger.ColorGreen Reset = logger.ColorReset )
Variables ¶
This section is empty.
Functions ¶
func PromptPassword ¶ added in v1.4.1
PromptPassword prompts the user for a password on the terminal without echoing.
Types ¶
type ConsoleReporter ¶
type ConsoleReporter struct {
// contains filtered or unexported fields
}
ConsoleReporter implements Reporter using go-pretty for console output.
func NewConsoleReporter ¶
func NewConsoleReporter() *ConsoleReporter
func (*ConsoleReporter) SetLogWriter ¶
func (c *ConsoleReporter) SetLogWriter(w *SafeLogWriter)
SetLogWriter registers a SafeLogWriter that will be kept in sync with the active progress writer so external log lines (e.g. store debug output) render cleanly above the progress bar.
func (*ConsoleReporter) StartPhase ¶
func (c *ConsoleReporter) StartPhase(name string, total int64, isBytes bool) Phase
type NoOpReporter ¶
type NoOpReporter struct{}
NoOpReporter implements Reporter doing nothing (for tests or silent mode).
func NewNoOpReporter ¶
func NewNoOpReporter() *NoOpReporter
func (*NoOpReporter) StartPhase ¶
func (n *NoOpReporter) StartPhase(name string, total int64, isBytes bool) Phase
type Reporter ¶
type Reporter interface {
// StartPhase starts a new progress tracking phase.
// name: Description of the phase.
// total: Total items/bytes to process. 0 for indeterminate.
// isBytes: If true, units are bytes, otherwise count.
StartPhase(name string, total int64, isBytes bool) Phase
}
Reporter defines the interface for progress reporting.
type SafeLogWriter ¶
type SafeLogWriter struct {
// contains filtered or unexported fields
}
SafeLogWriter is an io.Writer that coexists with go-pretty progress bars. When a progress writer is active, lines are routed through pw.Log() so they render above the bar. Otherwise lines go straight to stderr.
func (*SafeLogWriter) ClearActive ¶
func (w *SafeLogWriter) ClearActive()
ClearActive unregisters the progress writer.
func (*SafeLogWriter) SetActive ¶
func (w *SafeLogWriter) SetActive(pw progress.Writer)
SetActive registers the progress writer that is currently rendering.
type TermWriter ¶
TermWriter provides helpers for styled terminal output.
func NewTermWriter ¶
func NewTermWriter(w io.Writer) TermWriter
NewTermWriter returns a TermWriter targeting the given writer.
func (TermWriter) Blank ¶
func (t TermWriter) Blank()
func (TermWriter) Command ¶
func (t TermWriter) Command(name, args string)
func (TermWriter) Commands ¶
func (t TermWriter) Commands(cmds [][2]string)
func (TermWriter) Examples ¶
func (t TermWriter) Examples(cmds ...string)
func (TermWriter) Flags ¶
func (t TermWriter) Flags(flags [][2]string)
func (TermWriter) Heading ¶
func (t TermWriter) Heading(title string)
func (TermWriter) HeadingSub ¶
func (t TermWriter) HeadingSub(title, subtitle string)
func (TermWriter) Note ¶
func (t TermWriter) Note(lines ...string)