Documentation ¶
Index ¶
- Constants
- func Ago(ts time.Time) string
- func Color256(b byte) string
- func Every(d time.Duration) string
- func FprintKV(wr io.Writer, k string, v ...any) (int, error)
- func IsATTY(f *os.File) bool
- func Mods(str string, mods ...string) string
- func NewANSIStripper(wr io.Writer) io.Writer
- func NewIndenter(w io.Writer, indent string) io.Writer
- func PrettyBytes(b int64) string
- func PrettyDuration(left time.Duration) string
- func QRCode(buf string)
- func ReIndentJSON(j []byte, prefix, indent string) ([]byte, error)
- func StripANSI(s string) string
- func TrueColor(r, g, b byte) string
- type WriteSyncer
Constants ¶
const ( RunesAlpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" RunesAlphaNumeric = RunesAlpha + "0123456789" )
const ( FgBlack = "\x1b[30m" FgRed = "\x1b[31m" FgGreen = "\x1b[32m" FgYellow = "\x1b[33m" FgBlue = "\x1b[34m" FgMagenta = "\x1b[35m" FgCyan = "\x1b[36m" FgWhite = "\x1b[37m" FgDefault = "\x1b[39m" BgBlack = "\x1b[40m" BgRed = "\x1b[41m" BgGreen = "\x1b[42m" BgYellow = "\x1b[43m" BgBlue = "\x1b[44m" BgMagenta = "\x1b[45m" BgCyan = "\x1b[46m" BgWhite = "\x1b[47m" BgDefault = "\x1b[49m" FgBrightBlack = "\x1b[90m" FgBrightRed = "\x1b[91m" FgBrightGreen = "\x1b[92m" FgBrightYellow = "\x1b[93m" FgBrightBlue = "\x1b[94m" FgBrightMagenta = "\x1b[95m" FgBrightCyan = "\x1b[96m" FgBrightWhite = "\x1b[97m" BgBrightBlack = "\x1b[100m" BgBrightRed = "\x1b[101m" BgBrightGreen = "\x1b[102m" BgBrightYellow = "\x1b[103m" BgBrightBlue = "\x1b[104m" BgBrightMagenta = "\x1b[105m" BgBrightCyan = "\x1b[106m" BgBrightWhite = "\x1b[107m" Bold = "\x1b[1m" NoBold = "\x1b[22m" Underline = "\x1b[4m" NoUnderline = "\x1b[24m" Reset = "\x1b[0m" )
Variables ¶
This section is empty.
Functions ¶
func Ago ¶
Ago pretty prints a duration with an `ago` suffix. See: https://github.com/WireGuard/wireguard-tools/blob/71799a8f6d1450b63071a21cad6ed434b348d3d5/src/show.c#L157
func Every ¶
Every pretty prints a duration with an `every` prefix See: https://github.com/WireGuard/wireguard-tools/blob/71799a8f6d1450b63071a21cad6ed434b348d3d5/src/show.c#L176
func NewIndenter ¶
NewIndenter returns an io.Writer that prefixes the lines written to it with indent and then writes them to w. The writer returns the number of bytes written to the underlying Writer.
func PrettyBytes ¶
PrettyBytes pretty prints a byte count See: https://github.com/WireGuard/wireguard-tools/blob/71799a8f6d1450b63071a21cad6ed434b348d3d5/src/show.c#L184
func PrettyDuration ¶
PrettyDuration pretty prints a time just like `wg show` See: https://github.com/WireGuard/wireguard-tools/blob/71799a8f6d1450b63071a21cad6ed434b348d3d5/src/show.c#L129
Types ¶
type WriteSyncer ¶
func NewANSIStripperSynced ¶
func NewANSIStripperSynced(wr WriteSyncer) WriteSyncer