Documentation
¶
Index ¶
- Constants
- Variables
- func BEHelpDesc(actionName, desc string) string
- func BEUnavailableErr(featureName string) error
- func DecodeRef(s string) []string
- func EncodeRef(parts ...string) string
- func Exec(c tea.ExecCommand, fn tea.ExecCallback) tea.Cmd
- func ExecProcess(c *exec.Cmd, fn tea.ExecCallback) tea.Cmd
- func FeatureLockedCmd(featureName string) tea.Cmd
- func HasAction(name string) bool
- func IsTopLevel(name string) bool
- func RegisterAction(name string, fn Action)
- func RegisterGatedAction(name string, guard func() bool, fn Action)
- func RegisterTopLevel(name string)
- func RegisterView(name string, f Factory)
- func UnregisterActionForTest(name string)
- type Action
- type AppErrorMsg
- type AppInfoMsg
- type Factory
- type Filterable
- type GoBackMsg
- type NavigateToMsg
- type OpenConnectAppMsg
- type OpenUnlockDialogMsg
- type OpenUpdateDialogMsg
- type RestoreMouseMsg
- type RowClicker
- type ToggleMouseMsg
- type View
- type Warner
Constants ¶
const ( NameHelp = "help" NameStacks = "stacks" NameServices = "services" NameTasks = "tasks" NameNodes = "nodes" NameConfigs = "configs" NameSecrets = "secrets" NameContexts = "contexts" NameInspect = "inspect" NameLogs = "logs" NameLoading = "loading" NameNetworks = "networks" NameVolumes = "volumes" NameCharts = "charts" )
View name constants for type-safe navigation
const BELandingURL = "https://swarmcli.io/be"
BELandingURL is the public Business Edition landing page (trial info, feature overview). Exported so the BE module references the same string instead of re-hardcoding it.
Variables ¶
BEUnavailableFormat is the format string used by BEUnavailableErr. Contains one %s verb for the feature name. Override in init() to customise.
BEUnavailableFormatFn, if set, returns the error message for a feature. Takes precedence over BEUnavailableFormat. Override in init() to customise.
var FeatureLockedCmdFn func(featureName string) tea.Cmd
FeatureLockedCmdFn, if set by an extension, returns a tea.Cmd to run when a license-gated feature is requested without entitlement. When set it takes precedence over the caller's local error dialog, letting the extension show a richer prompt (e.g. an inline license dialog) instead of the flat BEUnavailableErr text. Override in init().
var ServicesHealthHint func() string
ServicesHealthHint, when set by the BE module, returns a one-line services- view footer note (e.g. why container health is unavailable on the current context), or "" when there is nothing to say. It lets BE surface a context- specific note without CE having to know about managed contexts. Set in init(); read on the render goroutine.
Functions ¶
func BEHelpDesc ¶
BEHelpDesc returns desc if the action is registered, or desc+" (BE)" if not.
func BEUnavailableErr ¶
BEUnavailableErr returns an error indicating a feature requires Business Edition.
func EncodeRef ¶
EncodeRef packs fields into one Action argument string. It is the shared contract for actions that need more than a bare resource name — e.g. volume actions need the swarm node ID plus the volume name, because a volume name is only unique per node. Decode with DecodeRef.
func Exec ¶ added in v2.2.0
func Exec(c tea.ExecCommand, fn tea.ExecCallback) tea.Cmd
Exec is ExecProcess for a tea.ExecCommand.
func ExecProcess ¶ added in v2.2.0
ExecProcess is tea.ExecProcess for a session that may have the mouse on.
Bubble Tea v1 switches mouse reporting off when it hands the terminal to the process and does not switch it back on when it takes the terminal back (charmbracelet/bubbletea#1424), so without this the mouse stays dead after an editor closes. The restore runs after the process has exited: Bubble Tea executes a sequence in order and the handover blocks its event loop.
func FeatureLockedCmd ¶
FeatureLockedCmd returns the extension's rich locked-feature command for featureName, or nil when no extension is registered — in which case callers fall back to surfacing BEUnavailableErr in their own error UI.
func IsTopLevel ¶
IsTopLevel reports whether a view name is a top-level (root) view.
func RegisterAction ¶
RegisterAction registers a named action. Must only be called from init() functions.
func RegisterGatedAction ¶
RegisterGatedAction registers an action with a runtime guard. GetAction and HasAction return false when the guard returns false. Must only be called from init() functions.
func RegisterTopLevel ¶
func RegisterTopLevel(name string)
RegisterTopLevel marks a view name as top-level. Called from init() by extension modules to register additional root views.
func RegisterView ¶
RegisterView registers a view factory under the given name. Must only be called from init() functions.
func UnregisterActionForTest ¶
func UnregisterActionForTest(name string)
UnregisterActionForTest removes a registered action. Test-only; not safe for concurrent use.
Types ¶
type Action ¶
Action is a feature action that can be triggered by key presses. The string parameter is the resource name (e.g. secret name). Registered during init() by extension packages, read-only after startup.
type AppErrorMsg ¶
AppErrorMsg signals that a view (or the app layer) encountered a loading error. The app shows a modal error dialog. On dismiss it navigates to FallbackView (if non-empty) or calls goBack().
type AppInfoMsg ¶
AppInfoMsg signals that a view (or the app layer) wants to show an informational notice — the AppErrorMsg counterpart for non-error content. The app shows the same modal styled as a neutral "Info" notice (not an error). On dismiss it navigates to FallbackView (if non-empty) or calls goBack(). Generic extension point: senders decide what warrants a notice.
type Factory ¶
Factory creates a View instance with its initial command. The deps parameter provides Docker operation interfaces for testability.
func GetFactory ¶
GetFactory returns the factory for the given view name.
type Filterable ¶
type Filterable interface {
ApplySearchQuery(query string)
ClearSearchQuery()
}
Filterable is an opt-in interface for views that support app-level "/" search filtering. Checked via type assertion in app/update.go.
type GoBackMsg ¶
type GoBackMsg struct{}
GoBackMsg requests the app to pop the current view and return to the previous one.
type NavigateToMsg ¶
type NavigateToMsg struct {
// view (i.e., not be pushed onto the navigation stack). When false,
// the view manager should push the new view onto the history stack.
Replace bool
}
type OpenConnectAppMsg ¶ added in v2.2.0
type OpenConnectAppMsg struct{}
OpenConnectAppMsg requests the app to open the popup that connects the SwarmCLI phone app (the "c" key and :connect).
type OpenUnlockDialogMsg ¶
type OpenUnlockDialogMsg struct{}
OpenUnlockDialogMsg requests the app to open the swarm unlock-key dialog.
type OpenUpdateDialogMsg ¶
type OpenUpdateDialogMsg struct {
Version string
}
OpenUpdateDialogMsg requests the app to force-show the "update available" notice on demand (the dev-only :dev-update command), bypassing the per-version dismissal. Version overrides the displayed latest version when set; otherwise the app falls back to the last checked version or a stub.
type RestoreMouseMsg ¶ added in v2.2.0
type RestoreMouseMsg struct{}
RestoreMouseMsg tells the app a terminal handover has switched mouse reporting off, so it switches it back on if the current view should have it. See ExecProcess.
type RowClicker ¶ added in v2.2.0
RowClicker is an opt-in interface for views whose content is a list of rows. The app turns a left click inside the frame into ClickRow, with line counted from the first content line below the header, and a second click on the same line in quick succession into an Enter keypress. ClickRow selects whatever row that line belongs to and reports whether there was one; a click on padding, a placeholder or anything else that is not a row returns false and changes nothing.
The app only calls it when nothing is capturing input, so a view does not have to check its own dialogs. Views without it get no mouse at all: the app switches mouse reporting off while one is current, so the text it shows selects natively. Checked via type assertion in app/mouse.go.
type ToggleMouseMsg ¶ added in v2.2.0
type ToggleMouseMsg struct{}
ToggleMouseMsg asks the app to switch mouse capture off, or back on, for the rest of the session.
type View ¶
type View interface {
Update(msg tea.Msg) tea.Cmd
View() string
Init() tea.Cmd
Name() string
ShortHelpItems() []helpbar.HelpEntry
OnEnter() tea.Cmd // Called when view becomes active
OnExit() tea.Cmd // Called when view is removed/replaced
HasErrors() bool // Returns true if the view has any errors to display
// Frame components — views return unframed content,
// app wraps with ui.RenderViewFrame.
FrameTitle() string // text for frame title bar
FrameHeader() string // rendered header line(s), "" if none
FrameContent() string // unframed content (may include dialog overlays)
}