Documentation
¶
Overview ¶
Package viewfmt holds the text and order the CLI and the terminal UI show servers with, so both describe a server the same way.
Index ¶
- Constants
- func HumanBytes(n int64) string
- func NextRunLabel(next, now time.Time) string
- func Note(s supervisor.View, now time.Time) string
- func Ordered(st *server.State) []supervisor.View
- func PlainLines(s string) []string
- func PlainRune(r rune) rune
- func PlainText(s string) string
- func SecretEnv(name, value string) bool
- func Sparkline(vals []float64, width int, floor float64) string
- func StateNote(s supervisor.View) string
- func StatusWord(s supervisor.View) string
- type FormatWriter
- type Group
Constants ¶
const SecretMask = "••••••"
SecretMask stands for a hidden value.
Variables ¶
This section is empty.
Functions ¶
func NextRunLabel ¶
NextRunLabel says concisely when a scheduled run is due: the time today, the weekday within a week, else the date (with the year when it differs).
func Note ¶
func Note(s supervisor.View, now time.Time) string
Note is the text after a server's status in lists: its state note, the worktree of a temporary copy and the next scheduled run.
func Ordered ¶
func Ordered(st *server.State) []supervisor.View
Ordered lists the servers as the dashboard does: groups in order of appearance, ungrouped servers last.
func PlainLines ¶
PlainLines is PlainText for text that may span lines: it splits s at line breaks (\n, \r\n and \r), turns tabs into spaces and makes each line safe; a trailing line break adds no empty line.
func PlainRune ¶
PlainRune is PlainText for one character: U+FFFD for an unsafe one, so text cleaned rune by rune keeps its rune positions.
func PlainText ¶
PlainText makes text from the daemon (a command, a folder, an env value) safe to print in a terminal: every control character, newlines included, and every format character that can reorder or hide text (bidirectional overrides, invisible separators) becomes U+FFFD. The zero-width joiner and non-joiner stay, since emoji and scripts need them. Invalid UTF-8 becomes U+FFFD too, so no stray byte reads as a C1 control.
func SecretEnv ¶
SecretEnv reports whether an environment variable's value is hidden until revealed: a name that suggests a secret, or a value that holds a password in a URL or a token in a query.
func Sparkline ¶
Sparkline draws vals as braille of exactly width cells, two samples per cell, the newest at the right.
func StateNote ¶
func StateNote(s supervisor.View) string
StateNote is the part of Note about the server's state: its note, who holds its port, where it is forwarded from and a changed config.
func StatusWord ¶
func StatusWord(s supervisor.View) string
StatusWord is the status a list prints: the status, "external" when another process holds a stopped server's port, or "done".
Types ¶
type FormatWriter ¶
type FormatWriter struct {
// contains filtered or unexported fields
}
FormatWriter passes program output to a terminal with every format character that can reorder or hide text (the ones PlainText replaces) turned into U+FFFD; control characters and escape sequences pass unchanged, for output that keeps its colors. A character split across writes, as WebSocket messages split output, is held until the rest arrives; Flush writes what is held at the end.
func NewFormatWriter ¶
func NewFormatWriter(w io.Writer) *FormatWriter
NewFormatWriter returns a FormatWriter writing to w.
func (*FormatWriter) Flush ¶
func (f *FormatWriter) Flush() error
Flush writes the bytes of an incomplete character held from the last write, which no later write completes.