fmtc

package
v3.7.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IconSuccess  = "✓"
	IconError    = "✗"
	IconWarning  = "⚠"
	IconInfo     = "ℹ"
	IconArrow    = "→"
	IconBullet   = "•"
	IconCheck    = "✔"
	IconCross    = "✘"
	IconStar     = "★"
	IconDot      = "●"
	IconCircle   = "○"
	IconSquare   = "■"
	IconTriangle = "▲"
	IconHeart    = "♥"
	IconSpinner  = "◐"
)

Icons for CLI output

View Source
const MaxVisibleItems = 15

MaxVisibleItems is the maximum number of items to show at once

Variables

View Source
var CommonHints = struct {
	Navigation   []HintItem
	Confirmation []HintItem
	Selection    []HintItem
	Editor       []HintItem
	Cancel       []HintItem
}{
	Navigation: []HintItem{
		{Key: "↑/↓", Description: "Navigate"},
		{Key: "Enter", Description: "Select"},
		{Key: "Ctrl+C", Description: "Cancel"},
	},
	Confirmation: []HintItem{
		{Key: "Y", Description: "Yes"},
		{Key: "N", Description: "No"},
		{Key: "Enter", Description: "Default"},
	},
	Selection: []HintItem{
		{Key: "↑/↓", Description: "Navigate"},
		{Key: "Enter", Description: "Select"},
		{Key: "0-9", Description: "Quick select"},
	},
	Editor: []HintItem{
		{Key: "Ctrl+S", Description: "Save"},
		{Key: "Ctrl+C", Description: "Cancel"},
		{Key: "Esc", Description: "Exit"},
	},
	Cancel: []HintItem{
		{Key: "Ctrl+C", Description: "Cancel"},
	},
}

CommonHints provides pre-defined hint sets

Functions

func Banner(title, subtitle string)

Banner displays a styled ASCII banner for setup

func BannerSimple

func BannerSimple(title string)

BannerSimple displays a simpler single-line banner

func ClearLine

func ClearLine()

ClearLine clears the current line

func ClearLines

func ClearLines(n int)

ClearLines clears n lines above current position

func Confirm

func Confirm(message string, defaultYes bool) bool

Confirm displays a confirmation prompt and returns the user's choice defaultYes determines if Enter defaults to Yes (true) or No (false)

func ConfirmBox

func ConfirmBox(title string, message string, defaultYes bool) bool

ConfirmBox displays a boxed confirmation prompt

func ConfirmWithOptions

func ConfirmWithOptions(message string, options []string, defaultIdx int) int

ConfirmWithOptions displays a confirmation with custom options

func ConfirmationHints

func ConfirmationHints()

ConfirmationHints displays confirmation hints

func ContextualHint

func ContextualHint(message string)

ContextualHint displays a contextual hint message

func DisplayPresetInfo

func DisplayPresetInfo(name, description string, details map[string]string)

DisplayPresetInfo shows information about a selected preset

func ErrorIcon

func ErrorIcon(txt string)

ErrorIcon prints error message with cross icon

func ErrorIconLn

func ErrorIconLn(txt string)

ErrorIconLn prints error message with cross icon and newline

func ErrorLn

func ErrorLn(txt string)

func Gray

func Gray() string

Gray returns the gray color code

func HelpBar

func HelpBar(items []HintItem)

HelpBar displays a formatted help bar at the bottom

func HelpBarBoxed

func HelpBarBoxed(items []HintItem)

HelpBarBoxed displays hints in a boxed format

func Hints

func Hints(items []HintItem)

Hints displays a help hints bar

func HintsCompact

func HintsCompact(items []HintItem)

HintsCompact displays hints in a more compact format

func HintsLine

func HintsLine(hints string)

HintsLine displays a single line of hints with separator

func InfoIcon

func InfoIcon(txt string)

InfoIcon prints info message with info icon

func InfoIconLn

func InfoIconLn(txt string)

InfoIconLn prints info message with info icon and newline

func InputPrompt

func InputPrompt(label string)

InputPrompt displays a styled input prompt

func InputPromptWithDefault

func InputPromptWithDefault(label, defaultVal string)

InputPromptWithDefault displays a prompt with default value hint

func NavigationHints()

NavigationHints displays standard navigation hints

func PrintArrow

func PrintArrow(message string)

PrintArrow prints a message with arrow

func PrintBullet

func PrintBullet(message string)

PrintBullet prints a bullet point

func PrintDivider

func PrintDivider(width int)

PrintDivider prints a horizontal divider

func PrintError

func PrintError(message string)

PrintError prints an error message with icon

func PrintHeader

func PrintHeader(title string)

PrintHeader prints a styled header

func PrintInfo

func PrintInfo(message string)

PrintInfo prints an info message with icon

func PrintKeyValue

func PrintKeyValue(key, value string)

PrintKeyValue prints a key-value pair with formatting

func PrintKeyValueError

func PrintKeyValueError(key, value string)

PrintKeyValueError prints a key-value pair with error icon

func PrintKeyValueSuccess

func PrintKeyValueSuccess(key, value string)

PrintKeyValueSuccess prints a key-value pair with success icon

func PrintList

func PrintList(items []string)

PrintList prints a list with bullets

func PrintNumberedList

func PrintNumberedList(items []string)

PrintNumberedList prints a numbered list

func PrintStep

func PrintStep(current, total int, message string)

PrintStep prints a step indicator

func PrintSubHeader

func PrintSubHeader(title string)

PrintSubHeader prints a sub-header

func PrintSuccess

func PrintSuccess(message string)

PrintSuccess prints a success message with icon

func PrintWarning

func PrintWarning(message string)

PrintWarning prints a warning message with icon

func ProceedPrompt

func ProceedPrompt(message string)

ProceedPrompt displays a "Press Enter to continue" prompt

func Purple

func Purple(txt string)

func ResetColor

func ResetColor() string

ResetColor returns the reset color code

func Section

func Section(title string, items []SectionItem)

Section displays a grouped section with a title and items

func SectionBox

func SectionBox(title string, items []SectionItem)

SectionBox displays a boxed section with items

func SelectPreset

func SelectPreset(title string, presets []PresetOption) int

SelectPreset displays an interactive preset selector and returns the selected index

func SelectionHints

func SelectionHints()

SelectionHints displays selection hints

func Selector

func Selector(title string, options []SelectorOption, recommendedKey string)

Selector displays a styled selection box

func SelectorSimple

func SelectorSimple(title string, options []string, recommendedIdx int)

SelectorSimple displays options without a box (for backward compatibility)

func ShowInputError

func ShowInputError(message string)

ShowInputError shows error and returns cursor for re-input

func SimpleSummary

func SimpleSummary(title string, items []SectionItem)

SimpleSummary displays a simple two-column summary

func StatusLine

func StatusLine(message string, success bool)

StatusLine prints a status line with icon based on success

func Success

func Success(txt string)

func SuccessIcon

func SuccessIcon(txt string)

SuccessIcon prints success message with checkmark icon

func SuccessIconLn

func SuccessIconLn(txt string)

SuccessIconLn prints success message with checkmark icon and newline

func SuccessLn

func SuccessLn(txt string)

func TaskStatus

func TaskStatus(task string, status string)

TaskStatus prints a task with its status

func Tip

func Tip(message string)

Tip displays a tip message

func Title

func Title(txt string)

func TitleLn

func TitleLn(txt string)

func ToDo

func ToDo(txt string)

func ToDoLn

func ToDoLn(txt string)

func ValidateNumericInput

func ValidateNumericInput(input string, min, max int) (int, bool)

ValidateNumericInput validates that input is a number within range

func ValidationError

func ValidationError(message string)

ValidationError displays an inline validation error

func ValidationHint

func ValidationHint(message string)

ValidationHint displays an inline hint

func ValidationWarning

func ValidationWarning(message string)

ValidationWarning displays an inline validation warning

func Warning

func Warning(txt string)

func WarningIcon

func WarningIcon(txt string)

WarningIcon prints warning message with warning icon

func WarningIconLn

func WarningIconLn(txt string)

WarningIconLn prints warning message with warning icon and newline

func WarningLn

func WarningLn(txt string)

func WithSpinner

func WithSpinner(message string, fn func() error) error

WithSpinner executes a function while showing a spinner

func WithSpinnerResult

func WithSpinnerResult(message string, fn func() (string, error)) error

WithSpinnerResult executes a function and returns custom success message

Types

type ConfigSection

type ConfigSection struct {
	Name  string
	Items []SectionItem
}

ConfigSection represents a section in the summary

type ConfigSummary

type ConfigSummary struct {
	Title    string
	Sections []ConfigSection
}

ConfigSummary displays a complete configuration summary with multiple sections

func (*ConfigSummary) Display

func (cs *ConfigSummary) Display()

Display shows the configuration summary

type HintItem

type HintItem struct {
	Key         string
	Description string
}

HintItem represents a single hint with key and description

type InteractiveSelector

type InteractiveSelector struct {
	Title       string
	Options     []string
	Selected    int
	Recommended int
	// contains filtered or unexported fields
}

InteractiveSelector displays an interactive selector with arrow key navigation

func NewInteractiveSelector

func NewInteractiveSelector(title string, options []string, recommended int) *InteractiveSelector

NewInteractiveSelector creates a new interactive selector

func (*InteractiveSelector) Run

func (s *InteractiveSelector) Run() (int, string)

Run displays the selector and returns the selected index and value

type PresetOption

type PresetOption struct {
	Name        string
	Description string
	IsCustom    bool
}

PresetOption represents a preset option for selection

type PromptWithValidation

type PromptWithValidation struct {
	Label       string
	Default     string
	Validator   func(string) (string, error)
	ErrorMsg    string
	MaxAttempts int
}

PromptWithValidation shows a prompt and validates input

func (*PromptWithValidation) Run

func (p *PromptWithValidation) Run() (string, error)

Run executes the prompt with validation

type SectionItem

type SectionItem struct {
	Key   string
	Value string
}

SectionItem represents a key-value pair in a section

type SelectorOption

type SelectorOption struct {
	Key         string
	Value       string
	Recommended bool
}

SelectorOption represents a single option in the selector

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner displays an animated spinner with a message

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with the given message

func NewSpinnerWithStyle

func NewSpinnerWithStyle(message string, style SpinnerStyle) *Spinner

NewSpinnerWithStyle creates a spinner with a specific style

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner and clears the line

func (*Spinner) StopWithError

func (s *Spinner) StopWithError(message string)

StopWithError stops and shows an error message

func (*Spinner) StopWithMessage

func (s *Spinner) StopWithMessage(message string)

StopWithMessage stops the spinner and shows a final message

func (*Spinner) StopWithSuccess

func (s *Spinner) StopWithSuccess(message string)

StopWithSuccess stops and shows a success message

func (*Spinner) StopWithWarning

func (s *Spinner) StopWithWarning(message string)

StopWithWarning stops and shows a warning message

func (*Spinner) UpdateMessage

func (s *Spinner) UpdateMessage(message string)

UpdateMessage updates the spinner message while running

type SpinnerStyle

type SpinnerStyle int

SpinnerStyle defines different spinner animations

const (
	SpinnerDots SpinnerStyle = iota
	SpinnerLine
	SpinnerCircle
	SpinnerBounce
)

type StepProgress

type StepProgress struct {
	// contains filtered or unexported fields
}

StepProgress manages and displays setup progress

func NewStepProgress

func NewStepProgress(steps []string) *StepProgress

NewStepProgress creates a new progress tracker

func (*StepProgress) Complete

func (sp *StepProgress) Complete()

Complete displays a completion message

func (*StepProgress) Display

func (sp *StepProgress) Display()

Display shows the current progress bar and step name

func (*StepProgress) DisplayCompact

func (sp *StepProgress) DisplayCompact()

DisplayCompact shows a compact single-line progress

func (*StepProgress) SetStep

func (sp *StepProgress) SetStep(step int)

SetStep sets the current step (1-indexed for user display)

Jump to

Keyboard shortcuts

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