Documentation
¶
Overview ¶
Package common holds tiny CLI utilities shared across mcpkit's single-purpose binaries (cmd/mcpskills today; cmd/mcpkit-auth and friends as they appear). Scope is deliberately narrow: env-var precedence helpers, TTY detection, and color helpers. Domain surfaces (mcpkit/client wrapper construction, server registration, etc.) live in the binaries themselves.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabled ¶
ColorEnabled reports whether w should receive ANSI color escapes under the given mode. ColorAuto checks whether w is a *os.File pointing at a TTY; non-file writers default to no color.
func LookupURL ¶
LookupURL returns the URL to target for a CLI invocation. Precedence (highest first):
- flag value (passed in by the caller after cobra's flag parsing)
- $<envVar> if set and non-empty
- defaultURL
Used by inspect-style subcommands that need a server URL with the usual flag-then-env-then-default pattern. Callers wire the flag.
Types ¶
type ColorMode ¶
type ColorMode int
ColorMode controls whether ANSI color escapes appear in output.
const ( // ColorAuto enables color when stdout is a TTY, disables it when // piped. Standard CLI behavior. ColorAuto ColorMode = iota // ColorAlways forces color on. Useful when the caller pipes into a // terminal-aware pager (e.g. less -R). ColorAlways // ColorNever disables color unconditionally. Used by --no-color and // for capture-and-diff tests. ColorNever )
type Painter ¶
type Painter struct {
// contains filtered or unexported fields
}
Painter wraps ANSI escape application so callers can write
fmt.Fprintln(out, p.Green("✓"), "git-workflow", p.Dim("(verified)"))
without sprinkling escape strings through the call sites. When color is disabled the methods return the input unchanged.
func NewPainter ¶
NewPainter constructs a Painter for w under the given mode.