tmpl

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(s string, v Vars) string

Expand replaces template placeholders in s with runtime values. {profile} → profile name as-is, {Profile} → title-cased, {command} → wrapped command string, {duration} → compact elapsed time, {Duration} → spoken elapsed time.

ORDER MATTERS: uppercase variants ({Duration}, {Time}, {Date}, {Profile}) must be replaced before their lowercase counterparts. Otherwise "{Duration}" partially matches "{duration}" (a prefix), producing corrupted output. Do not reorder these replacements.

func TitleCase

func TitleCase(s string) string

TitleCase uppercases the first byte of s.

Types

type Vars added in v0.2.0

type Vars struct {
	Profile     string
	Command     string
	Duration    string // compact: "2m15s"
	DurationSay string // spoken: "2 minutes and 15 seconds"
	Time        string // compact: "15:04"
	TimeSay     string // spoken: "3:04 PM"
	Date        string // compact: "2006-01-02"
	DateSay     string // spoken: "January 2, 2006"
	Hostname    string
	Output      string // last N lines of wrapped command output
}

Vars holds runtime values for template expansion.

Jump to

Keyboard shortcuts

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