ui

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ui provides terminal UI components for minectl using the Charm ecosystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(title string) (bool, error)

Confirm displays a yes/no confirmation prompt. Returns true if the user confirmed, false otherwise.

func FormTheme

func FormTheme() *huh.Theme

FormTheme returns a consistent theme for Huh forms.

func RunForm

func RunForm(form *huh.Form, headless bool) error

RunForm runs a Huh form with consistent styling. In headless mode, it will use accessible mode for better CI/CD compatibility.

Types

type Spinner

type Spinner struct {
	Message      string
	FinalMessage string
	ErrorMessage string
	// contains filtered or unexported fields
}

Spinner provides an animated spinner for long-running operations. In headless mode, it falls back to simple log messages.

func NewSpinner

func NewSpinner(message string, u *UI) *Spinner

NewSpinner creates a new animated spinner.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation.

func (*Spinner) Stop

func (s *Spinner) Stop(err error)

Stop stops the spinner and displays the appropriate final message.

type Table

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

Table wraps lipgloss table with minectl styling.

func NewTable

func NewTable(u *UI, headers ...string) *Table

NewTable creates a new styled table.

func (*Table) Append

func (t *Table) Append(row []string)

Append adds a row to the table.

func (*Table) Render

func (t *Table) Render()

Render prints the table to stdout.

func (*Table) RenderToWriter

func (t *Table) RenderToWriter(w io.Writer)

RenderToWriter writes the table to the given writer.

func (*Table) String

func (t *Table) String() string

String returns the table as a string.

type TableStyle

type TableStyle struct {
	HeaderStyle lipgloss.Style
	CellStyle   lipgloss.Style
	BorderStyle lipgloss.Style
}

TableStyle defines the visual style for tables.

func DefaultTableStyle

func DefaultTableStyle() TableStyle

DefaultTableStyle returns the default styling for tables.

type UI

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

UI provides a unified interface for terminal output that handles both interactive and headless modes. In interactive mode, it uses Charm components for polished output. In headless mode, it falls back to structured logging.

func NewUI

func NewUI(headless bool, log *logging.MinectlLogging) *UI

NewUI creates a new UI instance.

func (*UI) ErrorMsg

func (u *UI) ErrorMsg(err error)

ErrorMsg prints an error message with a red cross prefix.

func (*UI) Info

func (u *UI) Info(msg string)

Info prints an informational message with a dim/neutral style.

func (*UI) IsHeadless

func (u *UI) IsHeadless() bool

IsHeadless returns true if the UI is running in headless mode (CI/CD).

func (*UI) Logging

func (u *UI) Logging() *logging.MinectlLogging

Logging returns the underlying logging instance.

func (*UI) Success

func (u *UI) Success(msg string)

Success prints a success message with a green checkmark prefix.

func (*UI) Warn

func (u *UI) Warn(msg string)

Warn prints a warning message with a yellow warning prefix.

Jump to

Keyboard shortcuts

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