tmuxp.workspace.builder.WorkspaceBuilderProtocol
- Bases:
Contract a builder must satisfy to be driven by
tmuxp load.Description#
A conforming builder is constructed with at least
session_configandserver(plus the optionalpluginsandon_*callbacks the classic builder accepts). It exposesbuild, surfaces the populated tmux session viasession, and honors the plugin/progress integration points the CLI drives.Because the protocol carries data members (
session,plugins, theon_*callbacks), validate instances withisinstance; class-levelissubclasschecks are not supported for runtime-checkable protocols with non-method members.Examples#
A builder implementing the full contract satisfies the protocol:
>>> from tmuxp.workspace.builder.protocol import WorkspaceBuilderProtocol>>> class MiniBuilder:... plugins: list = []... on_progress = None... on_before_script = None... on_script_output = None... on_build_event = None... def __init__(self, session_config, server, **kwargs):... self._session_config = session_config... def build(self, session=None, append=False):... ...... def session_exists(self, session_name):... ...... def find_current_attached_session(self):... ...... @property... def session(self):... ...>>> builder = MiniBuilder(session_config={}, server=None)>>> isinstance(builder, WorkspaceBuilderProtocol)TrueAn object missing the contract does not:
>>> isinstance(object(), WorkspaceBuilderProtocol)FalseDiscussed in Python workspace internal API
Members
- on_progress : t
.Callable [[str], None] | None
- on_before_script : t
.Callable [[], None] | None
- on_script_output : t
.Callable [[str], None] | None
- on_build_event : t
.Callable [[dict[str, t.Any ]], None] | None
- __init__ ( self, session_config: dict[str, t
.Any ], server: Server, plugins: list[t.Any ] | None = None, on_progress: t.Callable [[str], None] | None = None, on_before_script: t.Callable [[], None] | None = None, on_script_output: t.Callable [[str], None] | None = None, on_build_event: t.Callable [[dict[str, t.Any ]], None] | None = None, ) None -
Construct a builder from an expanded workspace and a tmux server.
- Parameters
-
-
session_config(dict[str, t.Any ]) # -
on_progress(t.Callable [[str], None] | None) # -
on_before_script(t.Callable [[], None] | None) # -
on_script_output(t.Callable [[str], None] | None) # -
on_build_event(t.Callable [[dict[str, t.Any ]], None] | None) #
-
-
Return the tmux session the builder created or populated.
-
Build the workspace, creating or populating a tmux session.
- session_exists (self, session_name: str) bool
-
Return
Trueif a session withsession_namealready exists.- Parameters
-
-
session_name(str) #
-
-
-
Return the session currently attached within
$TMUX.