Documentation
¶
Index ¶
- Constants
- Variables
- func Accent() lipgloss.TerminalColor
- func Accented(text string) string
- func Brand() lipgloss.TerminalColor
- func Confirm() *huh.Confirm
- func CopyFile(src, dest string) error
- func CreateTable() *table.Table
- func Dimmed(text string) string
- func EllipsizeTo(str string, maxLength int) string
- func Error() lipgloss.TerminalColor
- func ExpandTemplate(template string) string
- func ExtractSubdomain(url string) string
- func FileExists(dir fs.FS, filename string) bool
- func GitCurrentBranch(ctx context.Context, dir string) (string, error)
- func GitHeadCommit(ctx context.Context, dir string) (string, error)
- func GitWorkingTreeHash(ctx context.Context, dir string) (string, error)
- func HasUncommittedChanges(ctx context.Context, dir string) (bool, error)
- func HashString(str string) (string, error)
- func Hyperlink(url, label string) string
- func IsGitRepository(ctx context.Context, dir string) bool
- func MapStrings(strs []string, fn func(string) string) []string
- func MoveDir(src, dest string) error
- func OpenInConsole(dashboardURL, projectId string, params *ConsoleURLParams) error
- func OpenInMeet(livekitURL, token string) error
- func PrintJSON(obj any)
- func PrintJSONTo(w io.Writer, obj any) error
- func SetTheme(name string) error
- func Success() lipgloss.TerminalColor
- func ToUnixPath(p string) string
- func URLSafeName(projectURL string) (string, error)
- func UseTempPath(permanentPath string) (string, func() error, func() error)
- func Warning() lipgloss.TerminalColor
- func WrapToLines(input string, maxLineLength int) []string
- func WrapWith(wrap string) func(string) string
- type ConsoleURLParams
- type OpenTarget
- type Printer
- func (p *Printer) Await(title string, ctx context.Context, action func(ctx context.Context) error) error
- func (p *Printer) Interactive() bool
- func (p *Printer) Result(a ...any)
- func (p *Printer) ResultWriter() io.Writer
- func (p *Printer) Resultf(format string, a ...any)
- func (p *Printer) Status(a ...any)
- func (p *Printer) StatusWriter() io.Writer
- func (p *Printer) Statusf(format string, a ...any)
- func (p *Printer) WarnWriter() io.Writer
- func (p *Printer) Warnf(format string, a ...any)
- type ThemeName
Constants ¶
const ( MeetURL = "https://meet.livekit.io/custom" ConsoleURLPath = "/projects/%s/agents/console/?" )
Variables ¶
var ( // Theme is the huh form theme for the active color theme. Theme *huh.Theme Fg lipgloss.AdaptiveColor FormBaseStyle lipgloss.Style FormHeaderStyle lipgloss.Style )
Active theme state. Populated by applyTheme; switched once at startup via SetTheme. These are package-level so existing call sites (util.Theme, util.Accented, util.Fg, …) keep working; they are read at render time, which always happens after the theme is selected.
var ( OpenFlag = &cli.StringFlag{ Name: "open", Usage: fmt.Sprintf("Open relevant `APP` in browser, supported options: %v", options), Validator: func(input string) error { if !slices.Contains(options, input) { return fmt.Errorf("invalid open target: %s, supported options: %v", input, options) } return nil }, } )
var ValidThemes = []ThemeName{ThemeDefault, ThemeLiveKit}
ValidThemes lists the selectable theme names, for validation and help text.
Functions ¶
func Accent ¶ added in v2.16.5
func Accent() lipgloss.TerminalColor
func Accented ¶ added in v2.4.5
Accented renders text in the active theme's title style (brand color under livekit).
func Brand ¶ added in v2.16.5
func Brand() lipgloss.TerminalColor
Semantic color accessors. They read the active palette at call time, so they reflect the selected theme even when used to build styles lazily.
func Confirm ¶ added in v2.16.5
Confirm is a yes/no prompt styled by the active theme. It uses huh's built-in confirm field, which supports y/n quick entry (Accept: y/Y, Reject: n/N) and renders both choices as side-by-side buttons.
func CreateTable ¶
func EllipsizeTo ¶
func Error ¶ added in v2.16.5
func Error() lipgloss.TerminalColor
func ExpandTemplate ¶ added in v2.4.13
func ExtractSubdomain ¶ added in v2.4.6
func GitCurrentBranch ¶ added in v2.18.0
GitCurrentBranch returns the name of the currently checked-out branch. It returns an empty string (and no error) when HEAD is detached, since there is no meaningful branch to report.
func GitHeadCommit ¶ added in v2.18.0
GitHeadCommit returns the abbreviated SHA of the current HEAD commit. Git picks the shortest prefix that is unambiguous within the repository (min 7 chars, growing as needed), so the value uniquely identifies the commit in this repo. It errors when dir is not a git repository or has no commits yet.
func GitWorkingTreeHash ¶ added in v2.18.0
GitWorkingTreeHash returns an abbreviated, content-addressable SHA that uniquely identifies the exact current state of the working tree — including staged, unstaged, and untracked (but not ignored) files. This is useful for distinguishing dirty deploys that share the same HEAD commit. The snapshot is built in a throwaway index, so the user's staging area and working tree are left untouched. Two identical working trees produce the same hash. Like GitHeadCommit, the returned SHA is abbreviated to the shortest prefix that is unambiguous within the repository.
func HasUncommittedChanges ¶ added in v2.18.0
HasUncommittedChanges reports whether the working tree at dir has staged or unstaged changes, or untracked files (i.e. `git status` is not clean).
func HashString ¶
func Hyperlink ¶ added in v2.18.0
Hyperlink wraps label in an OSC 8 terminal hyperlink pointing at url. Terminals that support OSC 8 render label as a clickable link; others ignore the escape and show label unchanged. Gate calls on an interactive terminal (see Printer.Interactive) so the escape never leaks into piped/redirected output.
func IsGitRepository ¶ added in v2.18.0
IsGitRepository reports whether dir is inside a git working tree. It returns false (rather than an error) when git is not installed or dir is not tracked, so callers can treat "no git" as a soft, non-fatal condition.
func OpenInConsole ¶ added in v2.16.1
func OpenInConsole(dashboardURL, projectId string, params *ConsoleURLParams) error
func OpenInMeet ¶ added in v2.4.13
func SetTheme ¶ added in v2.16.5
SetTheme selects the active theme by name. An empty name resolves to the default. It returns an error for any other unrecognized name (used to validate `lk set-theme`).
func Success ¶ added in v2.16.5
func Success() lipgloss.TerminalColor
func ToUnixPath ¶ added in v2.5.2
Converts a path (possibly Windows-style) to a Unix-style path.
func URLSafeName ¶
func UseTempPath ¶
Provides a temporary path, a function to relocate it to a permanent path, and a function to clean up the temporary path that should always be deferred in the case of a failure to relocate.
func Warning ¶ added in v2.16.5
func Warning() lipgloss.TerminalColor
func WrapToLines ¶
Types ¶
type ConsoleURLParams ¶ added in v2.16.1
type ConsoleURLParams struct {
AgentName string `url:"agentName,omitempty"`
Deployment string `url:"deployment,omitempty"`
JobMetadata string `url:"jobMetadata,omitempty"`
RoomName string `url:"roomName,omitempty"`
RoomMetadata string `url:"roomMetadata,omitempty"`
Identity string `url:"identity,omitempty"`
Metadata string `url:"metadata,omitempty"`
Attributes map[string]string `url:"attributes,omitempty"`
Hidden bool `url:"hidden,omitempty"`
AutoStart bool `url:"autoStart,omitempty"`
}
type OpenTarget ¶ added in v2.4.13
type OpenTarget string
const ( OpenTargetMeet OpenTarget = "meet" OpenTargetConsole OpenTarget = "console" )
type Printer ¶ added in v2.16.5
type Printer struct {
Out io.Writer // primary output: data the user might pipe or redirect
Err io.Writer // status, warnings, diagnostics
Quiet bool // suppresses Status (warnings and errors still print)
// contains filtered or unexported fields
}
Printer is a single sink for human-facing CLI output. One instance per process is initialized from the root command and reused everywhere, so all status, warning, and result lines share consistent streams and gating.
func NewPrinter ¶ added in v2.16.5
NewPrinter builds a Printer targeting the given writers. Pass nil to default to os.Stdout / os.Stderr; this is the path tests use with bytes.Buffer.
func (*Printer) Await ¶ added in v2.16.5
func (p *Printer) Await(title string, ctx context.Context, action func(ctx context.Context) error) error
Await runs action while showing a spinner, then returns the action's error.
The spinner is decoration: it only animates when the Printer targets an interactive terminal and is not in quiet mode. Otherwise Await emits the title once as a plain status line (itself suppressed by --quiet) and runs the action without animation, so redirected/piped/CI output stays free of escape sequences and --quiet stays silent.
func (*Printer) Interactive ¶ added in v2.18.0
Interactive reports whether status output is going to a real terminal, so callers can gate terminal-only escapes (e.g. OSC 8 hyperlinks) and avoid leaking them into piped or redirected output.
func (*Printer) Result ¶ added in v2.16.5
Result writes the command's primary output to stdout. Always printed.
func (*Printer) ResultWriter ¶ added in v2.16.5
ResultWriter is the streaming counterpart of Result: always printed.
func (*Printer) Status ¶ added in v2.16.5
Status writes an informational breadcrumb to stderr ("Using project [X]", "Cloning template…"). Suppressed by --quiet. A trailing newline is appended.
func (*Printer) StatusWriter ¶ added in v2.16.5
StatusWriter is the streaming counterpart of Status: io.Discard under --quiet.
func (*Printer) WarnWriter ¶ added in v2.16.5
WarnWriter is the streaming counterpart of Warnf: never silenced.