tui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tui provides terminal-based UI for MindTrial CLI.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInteractiveMode is returned when interactive mode encounters an error.
	ErrInteractiveMode = errors.New("interactive mode error")

	// ErrTerminalRequired is returned when interactive mode is attempted
	// in a non-terminal environment.
	ErrTerminalRequired = errors.New("interactive mode requires a terminal environment")
)

Functions

func IsTerminal

func IsTerminal() bool

IsTerminal reports whether the current output is connected to a terminal.

Types

type ConsoleBuffer

type ConsoleBuffer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConsoleBuffer is a thread-safe buffer for storing console logs.

func (*ConsoleBuffer) String

func (cb *ConsoleBuffer) String() string

String returns the accumulated string in a thread-safe manner.

func (*ConsoleBuffer) Write

func (cb *ConsoleBuffer) Write(p []byte) (int, error)

Write writes p to the buffer in a thread-safe manner. It implements the io.Writer interface.

type TaskMonitor

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

TaskMonitor represents an interactive terminal UI for monitoring task execution. It displays real-time progress, logs, and handles user input during task execution. It wraps a runners.Runner implementation to execute tasks while providing visual feedback.

func NewTaskMonitor

func NewTaskMonitor(runner runners.Runner, console *ConsoleBuffer) *TaskMonitor

NewTaskMonitor initializes and returns a TaskMonitor. It accepts a pointer to a console buffer where an external logger writes during task execution. The TaskMonitor can read directly from this buffer to update the UI console component.

func (*TaskMonitor) Run

func (t *TaskMonitor) Run(ctx context.Context, tasks []config.Task) (userAction UserInputEvent, result runners.AsyncResultSet, err error)

Run runs tasks in an interactive UI, displaying real-time progress and logs. It returns the user action and the run result set.

type UserInputEvent

type UserInputEvent int

UserInputEvent represents the type of user actions in an interactive session.

const (
	// Exit indicates that the user wants to exit the application.
	Exit UserInputEvent = iota
	// Quit indicates that the user wants to quit the current interactive screen while continuing execution.
	Quit
	// Continue indicates that the user wants to proceed with the current selections.
	Continue
)

func DisplayRunConfigurationPicker

func DisplayRunConfigurationPicker(providers []config.ProviderConfig) (UserInputEvent, error)

DisplayRunConfigurationPicker displays a terminal UI for enabling or disabling run configurations. It returns the selected user action and an error if the selection fails. This function modifies the providers slice directly.

func DisplayTaskPicker

func DisplayTaskPicker(taskConfig *config.TaskConfig) (UserInputEvent, error)

DisplayTaskPicker displays a terminal UI for enabling or disabling tasks. It returns the selected user action and an error if the selection fails. This function modifies the provided taskConfig directly.

Jump to

Keyboard shortcuts

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