Documentation
¶
Overview ¶
Package cliui owns terminal capability detection and human-facing rendering for the secondbox and secondbox-deploy commands. Domain and command packages pass typed values to this package; they do not construct terminal styles.
Index ¶
- func Sanitize(value string) string
- func WriteJSONPassthrough(output io.Writer, validated []byte) error
- type Activity
- type Background
- type Capabilities
- type ColorMode
- type ColorProfile
- type Column
- type CommandContract
- type FieldKind
- type FieldSpec
- type Form
- type FormHandles
- type GroupSpec
- type Help
- type HuhForm
- func AdvancedSettingsForm(bindings []TextBinding) HuhForm
- func CapacityReviewForm(summary string, accepted *bool) HuhForm
- func FinalInstallConfirmationForm(review string, accepted *bool) HuhForm
- func FinalUpdateConfirmationForm(review string, accepted *bool) HuhForm
- func PurgeConfirmationForm(expected string, answer *string) HuhForm
- func ResumeSelectionForm(options []Option, target *string) HuhForm
- func RetentionChoiceForm(target *string) HuhForm
- func StandardBundleSelectionForm(accepted *bool) HuhForm
- func UninstallConfirmationForm(review string, accepted *bool) HuhForm
- func WorkspaceChoiceForm(options []Option, target *string) HuhForm
- type Option
- type OutputKind
- type OutputMode
- type Pair
- type Phase
- type ProbeOptions
- type Renderer
- func (renderer Renderer) FormatHelp(help Help) string
- func (renderer Renderer) HumanOutput() bool
- func (renderer Renderer) StartActivity(ctx context.Context, name string) (*Activity, error)
- func (renderer Renderer) StyledDiagnostic() bool
- func (renderer Renderer) StyledOutput() bool
- func (renderer Renderer) WriteDeterminate(label string, current, total int64) error
- func (renderer Renderer) WriteError(problem error, hint string) error
- func (renderer Renderer) WriteHelp(help Help) error
- func (renderer Renderer) WritePhases(phases []Phase) error
- func (renderer Renderer) WriteSummary(summary Summary) error
- func (renderer Renderer) WriteTable(table Table) error
- type Row
- type Status
- type StreamCapabilities
- type Summary
- type Table
- type TextBinding
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Activity ¶
type Activity struct {
// contains filtered or unexported fields
}
Activity is a bounded lifecycle indicator. Complete must be called before any guest or subprocess stream is forwarded.
type Background ¶
type Background string
const ( BackgroundDark Background = "dark" BackgroundLight Background = "light" )
type Capabilities ¶
type Capabilities struct {
Input StreamCapabilities
Output StreamCapabilities
Diagnostic StreamCapabilities
Unicode bool
Dumb bool
CI bool
NoColor bool
Accessible bool
}
Capabilities intentionally describes stdin, stdout, and stderr separately. A redirected stdout must never disable a progress display on a TTY stderr.
func ForWriter ¶
func ForWriter(output, diagnostic io.Writer) Capabilities
ForWriter provides deterministic non-TTY defaults for injected buffers.
func Probe ¶
func Probe(options ProbeOptions) Capabilities
type ColorMode ¶
type ColorMode string
ColorMode controls ANSI color independently of the output representation.
func ParseColorMode ¶
type ColorProfile ¶
type ColorProfile string
const ( ProfileASCII ColorProfile = "ascii" ProfileANSI ColorProfile = "ansi" ProfileANSI256 ColorProfile = "ansi256" ProfileTrueColor ColorProfile = "truecolor" )
type CommandContract ¶
type CommandContract struct {
Command string
Output OutputKind
ReadsStdin bool
LongLived bool
ExitOwner string
}
CommandContract is the reviewable inventory used to prevent a new command from accidentally gaining presentation bytes.
type Form ¶
type Form interface {
Run(context.Context, FormHandles) error
}
Form is the command-facing boundary. Tests and non-interactive planners can inject an implementation without importing Charm.
type FormHandles ¶
type HuhForm ¶
type HuhForm struct{ Groups []GroupSpec }
func AdvancedSettingsForm ¶
func AdvancedSettingsForm(bindings []TextBinding) HuhForm
func CapacityReviewForm ¶
func FinalUpdateConfirmationForm ¶ added in v0.6.0
func PurgeConfirmationForm ¶
func ResumeSelectionForm ¶
func RetentionChoiceForm ¶
func WorkspaceChoiceForm ¶
type OutputKind ¶
type OutputKind string
OutputKind records a command's permanent stdout contract.
const ( OutputBoundedHuman OutputKind = "bounded-human" OutputMachineJSON OutputKind = "machine-json" OutputRawBytes OutputKind = "raw-bytes" OutputGuestStream OutputKind = "guest-stream" OutputSubprocess OutputKind = "subprocess" )
type OutputMode ¶
type OutputMode string
OutputMode selects the representation written by bounded commands.
const ( OutputAuto OutputMode = "auto" OutputJSON OutputMode = "json" OutputPlain OutputMode = "plain" )
func ParseOutputMode ¶
func ParseOutputMode(value string) (OutputMode, error)
type ProbeOptions ¶
type ProbeOptions struct {
Input *os.File
Output *os.File
Diagnostic *os.File
Environment []string
Size func(fd int) (width, height int, err error)
IsTerminal func(fd int) bool
ColorProfile func(output io.Writer, environment []string) colorprofile.Profile
DarkBackground func(input, output *os.File) bool
}
type Renderer ¶
type Renderer struct {
Output io.Writer
Diagnostic io.Writer
Capabilities Capabilities
OutputMode OutputMode
ColorMode ColorMode
}
func (Renderer) FormatHelp ¶
func (Renderer) HumanOutput ¶
func (Renderer) StartActivity ¶
func (Renderer) StyledDiagnostic ¶
func (Renderer) StyledOutput ¶
func (Renderer) WriteDeterminate ¶
WriteDeterminate writes one bounded progress snapshot. TTY diagnostics use the Bubbles progress renderer; redirected diagnostics receive plain counts.
func (Renderer) WritePhases ¶
func (Renderer) WriteSummary ¶
func (Renderer) WriteTable ¶
type StreamCapabilities ¶
type StreamCapabilities struct {
TTY bool
Width int
Height int
Color ColorProfile
Background Background
}