Documentation
¶
Overview ¶
Package commandruntime coordinates shared terminal handoff and runtime control flows.
Index ¶
- Constants
- func ActiveDisplayMessage(message io.Message, normalized string) string
- func CanPromptForMissingConfig(jsonOutput bool, assumeYes bool, isInputTerminal func() bool) bool
- func EncodeStatusEvent(kind StatusEventKind, operationID string, message string, level OutputLevel, ...) string
- func EnsureConfigRequirements(options ConfigRequirementOptions, requirements ...ConfigRequirement) error
- func EventEmoji(event StatusEvent) string
- func FinishProcess() tea.Msg
- func FormatCommandError(err error, debug bool) string
- func FormatMessageWithEmoji(message io.Message) string
- func GetJiraIssueWithRetry(jiraClient JiraIssueLookupClient, issueID string, cfg JiraIssueLookupConfig, ...) (*jira.Issue, error)
- func HumanizeDuration(duration time.Duration) string
- func IsErrorMessage(message string) bool
- func IsInputTerminal() bool
- func IsKnownOutputLevel(level OutputLevel) bool
- func IsVisualPrefixToken(token string) bool
- func IsWarningMessage(message string) bool
- func NormalizeHTTPSRootURL(raw string, label string) (string, error)
- func NormalizeVisualPrefixSpacing(message string) string
- func OpenEditorWithTerminalHandoff(initialContent string, runWithTerminalHandoff func(func() error) error, ...) (string, error)
- func OperationIDOrDefault(operationID string) string
- func PrintDoneFooter(w io.Writer, start time.Time)
- func PromptForConfigRequirement(requirement ConfigRequirement) (string, error)
- func RedactSensitiveDebug(message string) string
- func SetBuildInfo(info BuildInfo)
- func ShouldPrintDoneFooter(suppressOutput bool, invocationShellCompletion bool, ...) bool
- func ShouldSkipStartupCommand(commandName string, isShellCompletion bool, helpRequested bool) bool
- func SplitVisualPrefix(message string) (string, string, bool)
- func SummarizeCommandError(err error) string
- func UpdateStatus(status string) tea.Msg
- type BuildInfo
- type BuildVersionCheckerFunc
- type ConfigRequirement
- type ConfigRequirementOptions
- type DoneMsg
- type HandoffError
- type HandoffStage
- type JiraIssueLookupClient
- type JiraIssueLookupConfig
- type LocalizeFunc
- type LocalizedEmitter
- func (e LocalizedEmitter) BridgeChannel() (*chan string, func())
- func (e LocalizedEmitter) Debug(key i18n.Key, args ...any)
- func (e LocalizedEmitter) DebugRaw(message string)
- func (e LocalizedEmitter) Debugf(format string, args ...any)
- func (e LocalizedEmitter) Error(operationID string, emoji LogEmoji, key i18n.Key, args ...any)
- func (e LocalizedEmitter) ErrorRaw(operationID string, emoji LogEmoji, message string)
- func (e LocalizedEmitter) Info(emoji LogEmoji, key i18n.Key, args ...any)
- func (e LocalizedEmitter) InfoRaw(emoji LogEmoji, message string)
- func (e LocalizedEmitter) Start(operationID string, emoji LogEmoji, key i18n.Key, args ...any)
- func (e LocalizedEmitter) StartRaw(operationID string, emoji LogEmoji, message string)
- func (e LocalizedEmitter) Success(operationID string, emoji LogEmoji, key i18n.Key, args ...any)
- func (e LocalizedEmitter) SuccessRaw(operationID string, emoji LogEmoji, message string)
- func (e LocalizedEmitter) Update(operationID string, emoji LogEmoji, key i18n.Key, args ...any)
- func (e LocalizedEmitter) UpdateRaw(operationID string, emoji LogEmoji, message string)
- func (e LocalizedEmitter) Verbose(key i18n.Key, args ...any)
- func (e LocalizedEmitter) VerboseRaw(message string)
- type LogEmoji
- type Manager
- func (m *Manager) CurrentTerminalController() TerminalController
- func (m *Manager) RunWithControllerHandoff(controller TerminalController, run func() error) error
- func (m *Manager) RunWithTerminalHandoff(run func() error) error
- func (m *Manager) WithActiveTerminal(controller TerminalController, fn func() error) error
- type OutputLevel
- type ShouldEmitLevelFunc
- type StartupAnnouncement
- type StartupAnnouncementManager
- type StartupAnnouncementProvider
- type StatusEmitter
- type StatusEvent
- type StatusEventKind
- type StatusModel
- type StatusModelOptions
- type StatusMsg
- type TerminalController
- type VersionAnnouncementProviderConfig
Constants ¶
const (
// AnnouncementKindUpdateBanner marks a startup announcement for version updates.
AnnouncementKindUpdateBanner = "update_banner"
)
const StatusEventPrefix = "__fotingo_status_event__:"
StatusEventPrefix marks encoded status events in the shared status channel.
Variables ¶
This section is empty.
Functions ¶
func ActiveDisplayMessage ¶
ActiveDisplayMessage returns the spinner-line text for active status entries.
func CanPromptForMissingConfig ¶
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 ¶
FinishProcess creates a completion message for the shared status model.
func FormatCommandError ¶
FormatCommandError returns user-facing command error text based on debug mode.
func FormatMessageWithEmoji ¶
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 ¶
HumanizeDuration formats durations using concise CLI-friendly output.
func IsErrorMessage ¶
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 ¶
IsVisualPrefixToken reports whether token should be treated as a visual (emoji/symbol) prefix.
func IsWarningMessage ¶
IsWarningMessage reports whether message content should be rendered with warning severity.
func NormalizeHTTPSRootURL ¶
NormalizeHTTPSRootURL validates and normalizes root URLs requiring the https scheme.
func NormalizeVisualPrefixSpacing ¶
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 ¶
OperationIDOrDefault normalizes operation IDs used by event streams.
func PrintDoneFooter ¶
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 ¶
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 ¶
ShouldSkipStartupCommand reports whether startup announcements should be skipped for a command.
func SplitVisualPrefix ¶
SplitVisualPrefix splits a non-alphanumeric prefix token from the message body.
func SummarizeCommandError ¶
SummarizeCommandError returns the top-level summary for user-facing errors.
func UpdateStatus ¶
UpdateStatus creates a status update message for the shared status model.
Types ¶
type BuildInfo ¶
BuildInfo holds release metadata injected at build time.
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 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 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 ¶
JiraIssueLookupClient is the subset required for retrying Jira issue lookups.
type JiraIssueLookupConfig ¶
JiraIssueLookupConfig controls retry behavior when looking up branch-derived Jira issues.
type LocalizeFunc ¶
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) 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) StartRaw ¶
func (e LocalizedEmitter) StartRaw(operationID string, emoji LogEmoji, message string)
StartRaw emits a raw start lifecycle event.
func (LocalizedEmitter) SuccessRaw ¶
func (e LocalizedEmitter) SuccessRaw(operationID string, emoji LogEmoji, message string)
SuccessRaw emits a raw success lifecycle event.
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 ¶
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.
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 ¶
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.