commandruntime

package
v1.9.3-0...-199195a Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 23 Imported by: 0

README

commandruntime

import "github.com/tagoro9/fotingo/internal/commandruntime"

Package commandruntime coordinates shared terminal handoff and runtime control flows.

Index

Constants

const (
    // AnnouncementKindUpdateBanner marks a startup announcement for version updates.
    AnnouncementKindUpdateBanner = "update_banner"
)

StatusEventPrefix marks encoded status events in the shared status channel.

const StatusEventPrefix = "__fotingo_status_event__:"

func ActiveDisplayMessage

func ActiveDisplayMessage(message io.Message, normalized string) string

ActiveDisplayMessage returns the spinner-line text for active status entries.

func CanPromptForMissingConfig

func CanPromptForMissingConfig(jsonOutput bool, assumeYes bool, isInputTerminal func() bool) bool

CanPromptForMissingConfig reports whether interactive config prompts are allowed.

func EncodeStatusEvent

func EncodeStatusEvent(kind StatusEventKind, operationID string, message string, level OutputLevel, emoji LogEmoji) string

EncodeStatusEvent serializes a status event with the shared envelope prefix.

func EnsureConfigRequirements

func EnsureConfigRequirements(options ConfigRequirementOptions, requirements ...ConfigRequirement) error

EnsureConfigRequirements resolves and persists missing config values using the supplied options.

func EventEmoji

func EventEmoji(event StatusEvent) string

EventEmoji resolves the displayed emoji for a status event.

func FinishProcess

func FinishProcess() tea.Msg

FinishProcess creates a completion message for the shared status model.

func FormatCommandError

func FormatCommandError(err error, debug bool) string

FormatCommandError returns user-facing command error text based on debug mode.

func FormatMessageWithEmoji

func FormatMessageWithEmoji(message io.Message) string

FormatMessageWithEmoji expands aliases and normalizes spacing between emoji prefixes and text.

func GetJiraIssueWithRetry

func GetJiraIssueWithRetry(jiraClient JiraIssueLookupClient, issueID string, cfg JiraIssueLookupConfig, debugf func(format string, args ...any)) (*jira.Issue, error)

GetJiraIssueWithRetry fetches a Jira issue with bounded retries.

func HumanizeDuration

func HumanizeDuration(duration time.Duration) string

HumanizeDuration formats durations using concise CLI-friendly output.

func IsErrorMessage

func IsErrorMessage(message string) bool

IsErrorMessage reports whether message content should be rendered with error severity.

func IsInputTerminal

func IsInputTerminal() bool

IsInputTerminal reports whether stdin points to an interactive terminal.

func IsKnownOutputLevel

func IsKnownOutputLevel(level OutputLevel) bool

IsKnownOutputLevel reports whether a level belongs to the known output-level set.

func IsVisualPrefixToken

func IsVisualPrefixToken(token string) bool

IsVisualPrefixToken reports whether token should be treated as a visual (emoji/symbol) prefix.

func IsWarningMessage

func IsWarningMessage(message string) bool

IsWarningMessage reports whether message content should be rendered with warning severity.

func NormalizeHTTPSRootURL

func NormalizeHTTPSRootURL(raw string, label string) (string, error)

NormalizeHTTPSRootURL validates and normalizes root URLs requiring the https scheme.

func NormalizeVisualPrefixSpacing

func NormalizeVisualPrefixSpacing(message string) string

NormalizeVisualPrefixSpacing normalizes spacing after visual prefix tokens.

func OpenEditorWithTerminalHandoff

func OpenEditorWithTerminalHandoff(initialContent string, runWithTerminalHandoff func(func() error) error, openEditor func(string) (string, error)) (string, error)

OpenEditorWithTerminalHandoff runs an editor call while safely releasing/restoring terminal ownership.

func OperationIDOrDefault

func OperationIDOrDefault(operationID string) string

OperationIDOrDefault normalizes operation IDs used by event streams.

func PrintDoneFooter

func PrintDoneFooter(w io.Writer, start time.Time)

PrintDoneFooter writes the completion footer to the provided writer.

func PromptForConfigRequirement

func PromptForConfigRequirement(requirement ConfigRequirement) (string, error)

PromptForConfigRequirement asks the user for one missing config value.

func RedactSensitiveDebug

func RedactSensitiveDebug(message string) string

RedactSensitiveDebug redacts common credential patterns from debug messages.

func SetBuildInfo

func SetBuildInfo(info BuildInfo)

SetBuildInfo updates the process-wide build metadata snapshot.

func ShouldPrintDoneFooter

func ShouldPrintDoneFooter(suppressOutput bool, invocationShellCompletion bool, shellCompletionRequest bool) bool

ShouldPrintDoneFooter reports whether a command should print the completion footer.

func ShouldSkipStartupCommand

func ShouldSkipStartupCommand(commandName string, isShellCompletion bool, helpRequested bool) bool

ShouldSkipStartupCommand reports whether startup announcements should be skipped for a command.

func SplitVisualPrefix

func SplitVisualPrefix(message string) (string, string, bool)

SplitVisualPrefix splits a non-alphanumeric prefix token from the message body.

func SummarizeCommandError

func SummarizeCommandError(err error) string

SummarizeCommandError returns the top-level summary for user-facing errors.

func UpdateStatus

func UpdateStatus(status string) tea.Msg

UpdateStatus creates a status update message for the shared status model.

type BuildInfo

BuildInfo holds release metadata injected at build time.

type BuildInfo struct {
    Version   string
    GitCommit string
    BuildTime string
    Platform  string
}

func GetBuildInfo
func GetBuildInfo() BuildInfo

GetBuildInfo returns the process-wide build metadata snapshot.

type BuildVersionCheckerFunc

BuildVersionCheckerFunc builds a version checker and optional cache store.

type BuildVersionCheckerFunc func() (*version.Checker, cache.Store, func(), error)

type ConfigRequirement

ConfigRequirement describes one required config value and optional prompt metadata.

type ConfigRequirement struct {
    Key         string
    EnvVar      string
    Prompt      string
    Placeholder string
    Validate    func(string) (string, error)
}

type ConfigRequirementOptions

ConfigRequirementOptions provides callbacks required to resolve missing config values.

type ConfigRequirementOptions struct {
    GetValue  func(key string) string
    CanPrompt func() bool
    Prompt    func(requirement ConfigRequirement) (string, error)
    Persist   func(key string, value string) error
}

type DoneMsg

DoneMsg signals that the status model should stop rendering.

type DoneMsg bool

type HandoffError

HandoffError captures which part of terminal ownership transition failed.

type HandoffError struct {
    Stage HandoffStage
    Err   error
}

func (*HandoffError) Error
func (e *HandoffError) Error() string

func (*HandoffError) Unwrap
func (e *HandoffError) Unwrap() error

type HandoffStage

HandoffStage identifies which handoff phase failed.

type HandoffStage string

const (
    HandoffStageRelease HandoffStage = "release"
    HandoffStageRestore HandoffStage = "restore"
)

type JiraIssueLookupClient

JiraIssueLookupClient is the subset required for retrying Jira issue lookups.

type JiraIssueLookupClient interface {
    GetJiraIssue(issueID string) (*jira.Issue, error)
}

type JiraIssueLookupConfig

JiraIssueLookupConfig controls retry behavior when looking up branch-derived Jira issues.

type JiraIssueLookupConfig struct {
    MaxAttempts int
    Delay       time.Duration
    Sleep       func(time.Duration)
}

type LocalizeFunc

LocalizeFunc renders translation keys into localized text.

type LocalizeFunc func(key i18n.Key, args ...any) string

type LocalizedEmitter

LocalizedEmitter wraps StatusEmitter with localization-aware helpers used by command flows.

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

func NewLocalizedEmitter
func NewLocalizedEmitter(statusCh chan<- string, shouldEmit ShouldEmitLevelFunc, localize LocalizeFunc) LocalizedEmitter

NewLocalizedEmitter creates a localization-aware status emitter for command workflows.

func (LocalizedEmitter) BridgeChannel
func (e LocalizedEmitter) BridgeChannel() (*chan string, func())

BridgeChannel returns a temporary status channel that forwards raw status messages to this emitter destination. Call the returned cleanup function to close the bridge and wait for forwarding to finish.

func (LocalizedEmitter) Debug
func (e LocalizedEmitter) Debug(key i18n.Key, args ...any)

Debug emits a debug-level message from a localization key.

func (LocalizedEmitter) DebugRaw
func (e LocalizedEmitter) DebugRaw(message string)

DebugRaw emits a debug-level raw message.

func (LocalizedEmitter) Debugf
func (e LocalizedEmitter) Debugf(format string, args ...any)

Debugf emits a formatted debug-level message.

func (LocalizedEmitter) Error
func (e LocalizedEmitter) Error(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Error emits an error lifecycle event from a localization key.

func (LocalizedEmitter) ErrorRaw
func (e LocalizedEmitter) ErrorRaw(operationID string, emoji LogEmoji, message string)

ErrorRaw emits a raw error lifecycle event.

func (LocalizedEmitter) Info
func (e LocalizedEmitter) Info(emoji LogEmoji, key i18n.Key, args ...any)

Info emits an info-level message from a localization key.

func (LocalizedEmitter) InfoRaw
func (e LocalizedEmitter) InfoRaw(emoji LogEmoji, message string)

InfoRaw emits an info-level raw message.

func (LocalizedEmitter) Start
func (e LocalizedEmitter) Start(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Start emits a start lifecycle event from a localization key.

func (LocalizedEmitter) StartRaw
func (e LocalizedEmitter) StartRaw(operationID string, emoji LogEmoji, message string)

StartRaw emits a raw start lifecycle event.

func (LocalizedEmitter) Success
func (e LocalizedEmitter) Success(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Success emits a success lifecycle event from a localization key.

func (LocalizedEmitter) SuccessRaw
func (e LocalizedEmitter) SuccessRaw(operationID string, emoji LogEmoji, message string)

SuccessRaw emits a raw success lifecycle event.

func (LocalizedEmitter) Update
func (e LocalizedEmitter) Update(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Update emits an update lifecycle event from a localization key.

func (LocalizedEmitter) UpdateRaw
func (e LocalizedEmitter) UpdateRaw(operationID string, emoji LogEmoji, message string)

UpdateRaw emits a raw update lifecycle event.

func (LocalizedEmitter) Verbose
func (e LocalizedEmitter) Verbose(key i18n.Key, args ...any)

Verbose emits a verbose-level message from a localization key.

func (LocalizedEmitter) VerboseRaw
func (e LocalizedEmitter) VerboseRaw(message string)

VerboseRaw emits a verbose-level raw message.

type LogEmoji

LogEmoji is the icon associated with a status message.

type LogEmoji string

const (
    LogEmojiNone      LogEmoji = ""
    LogEmojiSuccess   LogEmoji = "✨"
    LogEmojiRocket    LogEmoji = "🚀"
    LogEmojiWarning   LogEmoji = "⚠"
    LogEmojiError     LogEmoji = "💥"
    LogEmojiLink      LogEmoji = "🔗"
    LogEmojiBrowser   LogEmoji = "🌍"
    LogEmojiPackage   LogEmoji = "📦"
    LogEmojiBookmark  LogEmoji = "🔖"
    LogEmojiCheck     LogEmoji = "✅"
    LogEmojiUser      LogEmoji = "👤"
    LogEmojiGit       LogEmoji = "🌿"
    LogEmojiInfo      LogEmoji = "ℹ"
    LogEmojiPrompt    LogEmoji = "❓"
    LogEmojiDebug     LogEmoji = "🔍"
    LogEmojiVerbose   LogEmoji = "›"
    LogEmojiBranch    LogEmoji = "🌱"
    LogEmojiJira      LogEmoji = "🎫"
    LogEmojiGitHub    LogEmoji = "🐙"
    LogEmojiReview    LogEmoji = "👀"
    LogEmojiLabel     LogEmoji = "🏷"
    LogEmojiComment   LogEmoji = "💬"
    LogEmojiIssue     LogEmoji = "🧩"
    LogEmojiRelease   LogEmoji = "📦"
    LogEmojiChangelog LogEmoji = "📝"
    LogEmojiCommit    LogEmoji = "🧾"
    LogEmojiProgress  LogEmoji = "⏳"
    LogEmojiAuth      LogEmoji = "🔐"
    LogEmojiConfigure LogEmoji = "⚙"
    LogEmojiClipboard LogEmoji = "📋"
    LogEmojiReviewer  LogEmoji = "👥"
    LogEmojiMilestone LogEmoji = "🎯"
    LogEmojiLifecycle LogEmoji = "🔄"
    LogEmojiExternal  LogEmoji = "↗"
    LogEmojiTerminal  LogEmoji = "🖥"
    LogEmojiOperation LogEmoji = "⚡"
)

func DefaultEmojiForLevel
func DefaultEmojiForLevel(level OutputLevel) LogEmoji

DefaultEmojiForLevel returns the default emoji for a level when no explicit icon is provided.

type Manager

Manager coordinates terminal handoff for external interactive processes.

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

func NewManager
func NewManager() *Manager

func (*Manager) CurrentTerminalController
func (m *Manager) CurrentTerminalController() TerminalController

func (*Manager) RunWithControllerHandoff
func (m *Manager) RunWithControllerHandoff(controller TerminalController, run func() error) error

func (*Manager) RunWithTerminalHandoff
func (m *Manager) RunWithTerminalHandoff(run func() error) error

RunWithTerminalHandoff executes interactive subprocess work while temporarily releasing Bubble Tea terminal ownership, then restoring it afterwards.

func (*Manager) WithActiveTerminal
func (m *Manager) WithActiveTerminal(controller TerminalController, fn func() error) error

type OutputLevel

OutputLevel controls status-message visibility granularity.

type OutputLevel int

const (
    OutputLevelInfo OutputLevel = iota
    OutputLevelVerbose
    OutputLevelDebug
)

type ShouldEmitLevelFunc

ShouldEmitLevelFunc decides whether a message should be emitted for a level.

type ShouldEmitLevelFunc func(level OutputLevel) bool

type StartupAnnouncement

StartupAnnouncement is a user-facing startup message emitted before command execution.

type StartupAnnouncement struct {
    Emoji   LogEmoji
    Message string
    Kind    string
    Meta    map[string]string
}

type StartupAnnouncementManager

StartupAnnouncementManager stores and emits pending startup announcements.

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

func NewStartupAnnouncementManager
func NewStartupAnnouncementManager() *StartupAnnouncementManager

NewStartupAnnouncementManager creates a manager for startup announcement state.

func (*StartupAnnouncementManager) ConsumePending
func (m *StartupAnnouncementManager) ConsumePending() []StartupAnnouncement

ConsumePending drains and returns pending announcements.

func (*StartupAnnouncementManager) Prepare
func (m *StartupAnnouncementManager) Prepare(enabled bool, providers []StartupAnnouncementProvider) error

Prepare collects provider announcements when enabled and stores them as pending.

func (*StartupAnnouncementManager) SetPending
func (m *StartupAnnouncementManager) SetPending(announcements []StartupAnnouncement)

SetPending replaces pending announcements atomically.

type StartupAnnouncementProvider

StartupAnnouncementProvider generates startup announcements.

type StartupAnnouncementProvider interface {
    Announcements() ([]StartupAnnouncement, error)
}

func NewVersionAnnouncementProvider
func NewVersionAnnouncementProvider(config VersionAnnouncementProviderConfig) StartupAnnouncementProvider

NewVersionAnnouncementProvider creates a startup announcement provider that emits update notices.

type StatusEmitter

StatusEmitter writes structured status events into a shared channel.

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

func NewStatusEmitter
func NewStatusEmitter(statusCh chan<- string, shouldEmit ShouldEmitLevelFunc, redactDebug func(message string) string) StatusEmitter

NewStatusEmitter creates a StatusEmitter with visibility callbacks.

func (StatusEmitter) BridgeChannel
func (e StatusEmitter) BridgeChannel() (*chan string, func())

BridgeChannel returns a temporary status channel that forwards raw messages to this emitter destination. Call the returned cleanup function to close the bridge and wait for forwarding to finish.

func (StatusEmitter) Emit
func (e StatusEmitter) Emit(level OutputLevel, emoji LogEmoji, message string)

Emit appends a status message event.

func (StatusEmitter) EmitEvent
func (e StatusEmitter) EmitEvent(level OutputLevel, kind StatusEventKind, operationID string, emoji LogEmoji, message string)

EmitEvent emits a lifecycle status event for an operation.

type StatusEvent

StatusEvent is the structured representation of status updates crossing channels.

type StatusEvent struct {
    Kind        StatusEventKind `json:"kind"`
    OperationID string          `json:"operation_id,omitempty"`
    Message     string          `json:"message"`
    Level       OutputLevel     `json:"level,omitempty"`
    Emoji       LogEmoji        `json:"emoji,omitempty"`
}

func DecodeStatusEvent
func DecodeStatusEvent(raw string) (StatusEvent, bool)

DecodeStatusEvent parses an encoded status event from a raw string payload.

type StatusEventKind

StatusEventKind identifies the lifecycle stage of a status event.

type StatusEventKind string

const (
    StatusEventKindAppend  StatusEventKind = "append"
    StatusEventKindStart   StatusEventKind = "start"
    StatusEventKindUpdate  StatusEventKind = "update"
    StatusEventKindSuccess StatusEventKind = "success"
    StatusEventKindError   StatusEventKind = "error"
)

type StatusModel

StatusModel is the shared Bubble Tea model used by command flows.

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

func NewStatusModel
func NewStatusModel(options StatusModelOptions) StatusModel

NewStatusModel creates a status model with no preloaded messages.

func (StatusModel) Init
func (m StatusModel) Init() tea.Cmd

Init initializes the status model.

func (StatusModel) Update
func (m StatusModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the status model.

func (StatusModel) View
func (m StatusModel) View() string

View renders the status model.

type StatusModelOptions

StatusModelOptions configures the shared status model.

type StatusModelOptions struct {
    SuppressOutput func() bool
}

type StatusMsg

StatusMsg carries one status-channel update to the status model.

type StatusMsg string

type TerminalController

TerminalController controls Bubble Tea terminal ownership transitions.

type TerminalController interface {
    ReleaseTerminal() error
    RestoreTerminal() error
}

type VersionAnnouncementProviderConfig

VersionAnnouncementProviderConfig configures the version update startup announcement provider.

type VersionAnnouncementProviderConfig struct {
    CurrentVersion func() string
    BuildChecker   BuildVersionCheckerFunc
}

Generated by gomarkdoc

Documentation

Overview

Package commandruntime coordinates shared terminal handoff and runtime control flows.

Index

Constants

View Source
const (
	// AnnouncementKindUpdateBanner marks a startup announcement for version updates.
	AnnouncementKindUpdateBanner = "update_banner"
)
View Source
const StatusEventPrefix = "__fotingo_status_event__:"

StatusEventPrefix marks encoded status events in the shared status channel.

Variables

This section is empty.

Functions

func ActiveDisplayMessage

func ActiveDisplayMessage(message io.Message, normalized string) string

ActiveDisplayMessage returns the spinner-line text for active status entries.

func CanPromptForMissingConfig

func CanPromptForMissingConfig(jsonOutput bool, assumeYes bool, isInputTerminal func() bool) bool

CanPromptForMissingConfig reports whether interactive config prompts are allowed.

func EncodeStatusEvent

func EncodeStatusEvent(
	kind StatusEventKind,
	operationID string,
	message string,
	level OutputLevel,
	emoji LogEmoji,
) string

EncodeStatusEvent serializes a status event with the shared envelope prefix.

func EnsureConfigRequirements

func EnsureConfigRequirements(options ConfigRequirementOptions, requirements ...ConfigRequirement) error

EnsureConfigRequirements resolves and persists missing config values using the supplied options.

func EventEmoji

func EventEmoji(event StatusEvent) string

EventEmoji resolves the displayed emoji for a status event.

func FinishProcess

func FinishProcess() tea.Msg

FinishProcess creates a completion message for the shared status model.

func FormatCommandError

func FormatCommandError(err error, debug bool) string

FormatCommandError returns user-facing command error text based on debug mode.

func FormatMessageWithEmoji

func FormatMessageWithEmoji(message io.Message) string

FormatMessageWithEmoji expands aliases and normalizes spacing between emoji prefixes and text.

func GetJiraIssueWithRetry

func GetJiraIssueWithRetry(
	jiraClient JiraIssueLookupClient,
	issueID string,
	cfg JiraIssueLookupConfig,
	debugf func(format string, args ...any),
) (*jira.Issue, error)

GetJiraIssueWithRetry fetches a Jira issue with bounded retries.

func HumanizeDuration

func HumanizeDuration(duration time.Duration) string

HumanizeDuration formats durations using concise CLI-friendly output.

func IsErrorMessage

func IsErrorMessage(message string) bool

IsErrorMessage reports whether message content should be rendered with error severity.

func IsInputTerminal

func IsInputTerminal() bool

IsInputTerminal reports whether stdin points to an interactive terminal.

func IsKnownOutputLevel

func IsKnownOutputLevel(level OutputLevel) bool

IsKnownOutputLevel reports whether a level belongs to the known output-level set.

func IsVisualPrefixToken

func IsVisualPrefixToken(token string) bool

IsVisualPrefixToken reports whether token should be treated as a visual (emoji/symbol) prefix.

func IsWarningMessage

func IsWarningMessage(message string) bool

IsWarningMessage reports whether message content should be rendered with warning severity.

func NormalizeHTTPSRootURL

func NormalizeHTTPSRootURL(raw string, label string) (string, error)

NormalizeHTTPSRootURL validates and normalizes root URLs requiring the https scheme.

func NormalizeVisualPrefixSpacing

func NormalizeVisualPrefixSpacing(message string) string

NormalizeVisualPrefixSpacing normalizes spacing after visual prefix tokens.

func OpenEditorWithTerminalHandoff

func OpenEditorWithTerminalHandoff(
	initialContent string,
	runWithTerminalHandoff func(func() error) error,
	openEditor func(string) (string, error),
) (string, error)

OpenEditorWithTerminalHandoff runs an editor call while safely releasing/restoring terminal ownership.

func OperationIDOrDefault

func OperationIDOrDefault(operationID string) string

OperationIDOrDefault normalizes operation IDs used by event streams.

func PrintDoneFooter

func PrintDoneFooter(w io.Writer, start time.Time)

PrintDoneFooter writes the completion footer to the provided writer.

func PromptForConfigRequirement

func PromptForConfigRequirement(requirement ConfigRequirement) (string, error)

PromptForConfigRequirement asks the user for one missing config value.

func RedactSensitiveDebug

func RedactSensitiveDebug(message string) string

RedactSensitiveDebug redacts common credential patterns from debug messages.

func SetBuildInfo

func SetBuildInfo(info BuildInfo)

SetBuildInfo updates the process-wide build metadata snapshot.

func ShouldPrintDoneFooter

func ShouldPrintDoneFooter(
	suppressOutput bool,
	invocationShellCompletion bool,
	shellCompletionRequest bool,
) bool

ShouldPrintDoneFooter reports whether a command should print the completion footer.

func ShouldSkipStartupCommand

func ShouldSkipStartupCommand(commandName string, isShellCompletion bool, helpRequested bool) bool

ShouldSkipStartupCommand reports whether startup announcements should be skipped for a command.

func SplitVisualPrefix

func SplitVisualPrefix(message string) (string, string, bool)

SplitVisualPrefix splits a non-alphanumeric prefix token from the message body.

func SummarizeCommandError

func SummarizeCommandError(err error) string

SummarizeCommandError returns the top-level summary for user-facing errors.

func UpdateStatus

func UpdateStatus(status string) tea.Msg

UpdateStatus creates a status update message for the shared status model.

Types

type BuildInfo

type BuildInfo struct {
	Version   string
	GitCommit string
	BuildTime string
	Platform  string
}

BuildInfo holds release metadata injected at build time.

func GetBuildInfo

func GetBuildInfo() BuildInfo

GetBuildInfo returns the process-wide build metadata snapshot.

type BuildVersionCheckerFunc

type BuildVersionCheckerFunc func() (*version.Checker, cache.Store, func(), error)

BuildVersionCheckerFunc builds a version checker and optional cache store.

type ConfigRequirement

type ConfigRequirement struct {
	Key         string
	EnvVar      string
	Prompt      string
	Placeholder string
	Validate    func(string) (string, error)
}

ConfigRequirement describes one required config value and optional prompt metadata.

type ConfigRequirementOptions

type ConfigRequirementOptions struct {
	GetValue  func(key string) string
	CanPrompt func() bool
	Prompt    func(requirement ConfigRequirement) (string, error)
	Persist   func(key string, value string) error
}

ConfigRequirementOptions provides callbacks required to resolve missing config values.

type DoneMsg

type DoneMsg bool

DoneMsg signals that the status model should stop rendering.

type HandoffError

type HandoffError struct {
	Stage HandoffStage
	Err   error
}

HandoffError captures which part of terminal ownership transition failed.

func (*HandoffError) Error

func (e *HandoffError) Error() string

func (*HandoffError) Unwrap

func (e *HandoffError) Unwrap() error

type HandoffStage

type HandoffStage string

HandoffStage identifies which handoff phase failed.

const (
	HandoffStageRelease HandoffStage = "release"
	HandoffStageRestore HandoffStage = "restore"
)

type JiraIssueLookupClient

type JiraIssueLookupClient interface {
	GetJiraIssue(issueID string) (*jira.Issue, error)
}

JiraIssueLookupClient is the subset required for retrying Jira issue lookups.

type JiraIssueLookupConfig

type JiraIssueLookupConfig struct {
	MaxAttempts int
	Delay       time.Duration
	Sleep       func(time.Duration)
}

JiraIssueLookupConfig controls retry behavior when looking up branch-derived Jira issues.

type LocalizeFunc

type LocalizeFunc func(key i18n.Key, args ...any) string

LocalizeFunc renders translation keys into localized text.

type LocalizedEmitter

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

LocalizedEmitter wraps StatusEmitter with localization-aware helpers used by command flows.

func NewLocalizedEmitter

func NewLocalizedEmitter(
	statusCh chan<- string,
	shouldEmit ShouldEmitLevelFunc,
	localize LocalizeFunc,
) LocalizedEmitter

NewLocalizedEmitter creates a localization-aware status emitter for command workflows.

func (LocalizedEmitter) BridgeChannel

func (e LocalizedEmitter) BridgeChannel() (*chan string, func())

BridgeChannel returns a temporary status channel that forwards raw status messages to this emitter destination. Call the returned cleanup function to close the bridge and wait for forwarding to finish.

func (LocalizedEmitter) Debug

func (e LocalizedEmitter) Debug(key i18n.Key, args ...any)

Debug emits a debug-level message from a localization key.

func (LocalizedEmitter) DebugRaw

func (e LocalizedEmitter) DebugRaw(message string)

DebugRaw emits a debug-level raw message.

func (LocalizedEmitter) Debugf

func (e LocalizedEmitter) Debugf(format string, args ...any)

Debugf emits a formatted debug-level message.

func (LocalizedEmitter) Error

func (e LocalizedEmitter) Error(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Error emits an error lifecycle event from a localization key.

func (LocalizedEmitter) ErrorRaw

func (e LocalizedEmitter) ErrorRaw(operationID string, emoji LogEmoji, message string)

ErrorRaw emits a raw error lifecycle event.

func (LocalizedEmitter) Info

func (e LocalizedEmitter) Info(emoji LogEmoji, key i18n.Key, args ...any)

Info emits an info-level message from a localization key.

func (LocalizedEmitter) InfoRaw

func (e LocalizedEmitter) InfoRaw(emoji LogEmoji, message string)

InfoRaw emits an info-level raw message.

func (LocalizedEmitter) Start

func (e LocalizedEmitter) Start(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Start emits a start lifecycle event from a localization key.

func (LocalizedEmitter) StartRaw

func (e LocalizedEmitter) StartRaw(operationID string, emoji LogEmoji, message string)

StartRaw emits a raw start lifecycle event.

func (LocalizedEmitter) Success

func (e LocalizedEmitter) Success(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Success emits a success lifecycle event from a localization key.

func (LocalizedEmitter) SuccessRaw

func (e LocalizedEmitter) SuccessRaw(operationID string, emoji LogEmoji, message string)

SuccessRaw emits a raw success lifecycle event.

func (LocalizedEmitter) Update

func (e LocalizedEmitter) Update(operationID string, emoji LogEmoji, key i18n.Key, args ...any)

Update emits an update lifecycle event from a localization key.

func (LocalizedEmitter) UpdateRaw

func (e LocalizedEmitter) UpdateRaw(operationID string, emoji LogEmoji, message string)

UpdateRaw emits a raw update lifecycle event.

func (LocalizedEmitter) Verbose

func (e LocalizedEmitter) Verbose(key i18n.Key, args ...any)

Verbose emits a verbose-level message from a localization key.

func (LocalizedEmitter) VerboseRaw

func (e LocalizedEmitter) VerboseRaw(message string)

VerboseRaw emits a verbose-level raw message.

type LogEmoji

type LogEmoji string

LogEmoji is the icon associated with a status message.

const (
	LogEmojiNone      LogEmoji = ""
	LogEmojiSuccess   LogEmoji = "✨"
	LogEmojiRocket    LogEmoji = "🚀"
	LogEmojiWarning   LogEmoji = "⚠"
	LogEmojiError     LogEmoji = "💥"
	LogEmojiLink      LogEmoji = "🔗"
	LogEmojiBrowser   LogEmoji = "🌍"
	LogEmojiPackage   LogEmoji = "📦"
	LogEmojiBookmark  LogEmoji = "🔖"
	LogEmojiCheck     LogEmoji = "✅"
	LogEmojiUser      LogEmoji = "👤"
	LogEmojiGit       LogEmoji = "🌿"
	LogEmojiInfo      LogEmoji = "ℹ"
	LogEmojiPrompt    LogEmoji = "❓"
	LogEmojiDebug     LogEmoji = "🔍"
	LogEmojiVerbose   LogEmoji = "›"
	LogEmojiBranch    LogEmoji = "🌱"
	LogEmojiJira      LogEmoji = "🎫"
	LogEmojiGitHub    LogEmoji = "🐙"
	LogEmojiReview    LogEmoji = "👀"
	LogEmojiLabel     LogEmoji = "🏷"
	LogEmojiComment   LogEmoji = "💬"
	LogEmojiIssue     LogEmoji = "🧩"
	LogEmojiRelease   LogEmoji = "📦"
	LogEmojiChangelog LogEmoji = "📝"
	LogEmojiCommit    LogEmoji = "🧾"
	LogEmojiProgress  LogEmoji = "⏳"
	LogEmojiAuth      LogEmoji = "🔐"
	LogEmojiConfigure LogEmoji = "⚙"
	LogEmojiClipboard LogEmoji = "📋"
	LogEmojiReviewer  LogEmoji = "👥"
	LogEmojiMilestone LogEmoji = "🎯"
	LogEmojiLifecycle LogEmoji = "🔄"
	LogEmojiExternal  LogEmoji = "↗"
	LogEmojiTerminal  LogEmoji = "🖥"
	LogEmojiOperation LogEmoji = "⚡"
)

func DefaultEmojiForLevel

func DefaultEmojiForLevel(level OutputLevel) LogEmoji

DefaultEmojiForLevel returns the default emoji for a level when no explicit icon is provided.

type Manager

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

Manager coordinates terminal handoff for external interactive processes.

func NewManager

func NewManager() *Manager

func (*Manager) CurrentTerminalController

func (m *Manager) CurrentTerminalController() TerminalController

func (*Manager) RunWithControllerHandoff

func (m *Manager) RunWithControllerHandoff(controller TerminalController, run func() error) error

func (*Manager) RunWithTerminalHandoff

func (m *Manager) RunWithTerminalHandoff(run func() error) error

RunWithTerminalHandoff executes interactive subprocess work while temporarily releasing Bubble Tea terminal ownership, then restoring it afterwards.

func (*Manager) WithActiveTerminal

func (m *Manager) WithActiveTerminal(controller TerminalController, fn func() error) error

type OutputLevel

type OutputLevel int

OutputLevel controls status-message visibility granularity.

const (
	OutputLevelInfo OutputLevel = iota
	OutputLevelVerbose
	OutputLevelDebug
)

type ShouldEmitLevelFunc

type ShouldEmitLevelFunc func(level OutputLevel) bool

ShouldEmitLevelFunc decides whether a message should be emitted for a level.

type StartupAnnouncement

type StartupAnnouncement struct {
	Emoji   LogEmoji
	Message string
	Kind    string
	Meta    map[string]string
}

StartupAnnouncement is a user-facing startup message emitted before command execution.

type StartupAnnouncementManager

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

StartupAnnouncementManager stores and emits pending startup announcements.

func NewStartupAnnouncementManager

func NewStartupAnnouncementManager() *StartupAnnouncementManager

NewStartupAnnouncementManager creates a manager for startup announcement state.

func (*StartupAnnouncementManager) ConsumePending

func (m *StartupAnnouncementManager) ConsumePending() []StartupAnnouncement

ConsumePending drains and returns pending announcements.

func (*StartupAnnouncementManager) Prepare

func (m *StartupAnnouncementManager) Prepare(
	enabled bool,
	providers []StartupAnnouncementProvider,
) error

Prepare collects provider announcements when enabled and stores them as pending.

func (*StartupAnnouncementManager) SetPending

func (m *StartupAnnouncementManager) SetPending(announcements []StartupAnnouncement)

SetPending replaces pending announcements atomically.

type StartupAnnouncementProvider

type StartupAnnouncementProvider interface {
	Announcements() ([]StartupAnnouncement, error)
}

StartupAnnouncementProvider generates startup announcements.

func NewVersionAnnouncementProvider

func NewVersionAnnouncementProvider(config VersionAnnouncementProviderConfig) StartupAnnouncementProvider

NewVersionAnnouncementProvider creates a startup announcement provider that emits update notices.

type StatusEmitter

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

StatusEmitter writes structured status events into a shared channel.

func NewStatusEmitter

func NewStatusEmitter(
	statusCh chan<- string,
	shouldEmit ShouldEmitLevelFunc,
	redactDebug func(message string) string,
) StatusEmitter

NewStatusEmitter creates a StatusEmitter with visibility callbacks.

func (StatusEmitter) BridgeChannel

func (e StatusEmitter) BridgeChannel() (*chan string, func())

BridgeChannel returns a temporary status channel that forwards raw messages to this emitter destination. Call the returned cleanup function to close the bridge and wait for forwarding to finish.

func (StatusEmitter) Emit

func (e StatusEmitter) Emit(level OutputLevel, emoji LogEmoji, message string)

Emit appends a status message event.

func (StatusEmitter) EmitEvent

func (e StatusEmitter) EmitEvent(
	level OutputLevel,
	kind StatusEventKind,
	operationID string,
	emoji LogEmoji,
	message string,
)

EmitEvent emits a lifecycle status event for an operation.

type StatusEvent

type StatusEvent struct {
	Kind        StatusEventKind `json:"kind"`
	OperationID string          `json:"operation_id,omitempty"`
	Message     string          `json:"message"`
	Level       OutputLevel     `json:"level,omitempty"`
	Emoji       LogEmoji        `json:"emoji,omitempty"`
}

StatusEvent is the structured representation of status updates crossing channels.

func DecodeStatusEvent

func DecodeStatusEvent(raw string) (StatusEvent, bool)

DecodeStatusEvent parses an encoded status event from a raw string payload.

type StatusEventKind

type StatusEventKind string

StatusEventKind identifies the lifecycle stage of a status event.

const (
	StatusEventKindAppend  StatusEventKind = "append"
	StatusEventKindStart   StatusEventKind = "start"
	StatusEventKindUpdate  StatusEventKind = "update"
	StatusEventKindSuccess StatusEventKind = "success"
	StatusEventKindError   StatusEventKind = "error"
)

type StatusModel

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

StatusModel is the shared Bubble Tea model used by command flows.

func NewStatusModel

func NewStatusModel(options StatusModelOptions) StatusModel

NewStatusModel creates a status model with no preloaded messages.

func (StatusModel) Init

func (m StatusModel) Init() tea.Cmd

Init initializes the status model.

func (StatusModel) Update

func (m StatusModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the status model.

func (StatusModel) View

func (m StatusModel) View() string

View renders the status model.

type StatusModelOptions

type StatusModelOptions struct {
	SuppressOutput func() bool
}

StatusModelOptions configures the shared status model.

type StatusMsg

type StatusMsg string

StatusMsg carries one status-channel update to the status model.

type TerminalController

type TerminalController interface {
	ReleaseTerminal() error
	RestoreTerminal() error
}

TerminalController controls Bubble Tea terminal ownership transitions.

type VersionAnnouncementProviderConfig

type VersionAnnouncementProviderConfig struct {
	CurrentVersion func() string
	BuildChecker   BuildVersionCheckerFunc
}

VersionAnnouncementProviderConfig configures the version update startup announcement provider.

Jump to

Keyboard shortcuts

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