viewfmt

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const SecretMask = "••••••"

SecretMask stands for a hidden value.

Variables

This section is empty.

Functions

func HumanBytes

func HumanBytes(n int64) string

HumanBytes formats a memory size in KB, MB or GB.

func NextRunLabel

func NextRunLabel(next, now time.Time) string

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

func PlainLines(s string) []string

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

func PlainRune(r rune) rune

PlainRune is PlainText for one character: U+FFFD for an unsafe one, so text cleaned rune by rune keeps its rune positions.

func PlainText

func PlainText(s string) string

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

func SecretEnv(name, value string) bool

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

func Sparkline(vals []float64, width int, floor float64) string

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.

func (*FormatWriter) Write

func (f *FormatWriter) Write(p []byte) (int, error)

Write writes p with its hiding format characters replaced. It reports len(p) once the cleaned text is written, including bytes held for the next write.

type Group

type Group struct {
	Name    string
	Servers []supervisor.View
}

Group is one run of servers of the same group.

func Groups

func Groups(st *server.State) []Group

Groups splits Ordered into runs of one group each; ungrouped servers come last with an empty Name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL