LibTmux.Action (libtmux v0.1.3)

Copy Markdown View Source

Shared results for explicit pane, window and session actions.

Pass a LibTmux.Server for one-shot execution or a LibTmux.Control for managed execution in its qualified connection. No action changes transport, replays a mutation or refreshes an observation. Targeted one-shot actions check the server incarnation before execution; that check leaves a check/use race.

Ordinary actions return {:ok, result} only for completed commands. Failed, skipped and unknown outcomes return {:error, %LibTmux.Action.CompletionError{result: original_result}}. value holds the completed command's value; details retains the transport's original bounded evidence. Domain bang functions return the completed value or raise LibTmux.Action.CompletionError with the original unsuccessful result. Acknowledgement does not prove that a program processed input or finished running.

API errors use LibTmux.Error; admitted control errors preserve the recovery handle in LibTmux.Control.ExecutionError. Domain bang functions raise these errors unchanged. Lower-level LibTmux.Control and LibTmux.Operation bang functions retain canonical outcomes as values.

Action errors with kind :invalid_command include a validation path such as [:options, :size] and a bounded details.reason describing accepted inputs. The reason appears in the exception message; rejected values are not retained in diagnostic details. Targeted one-shot actions validate both native process specifications before the identity read. Session creation has no observed target; it validates its command and runs without an identity read. Native byte/count refusals use paths such as [:process, :argv] or [:process, :frame]. Preparation does not check filesystem existence or guarantee execution.

A nonzero one-shot client exit reports :failed with :observed certainty: its exit status is observed, not an authenticated tmux command reply or proof that no effects occurred.

Kill actions run one-shot only: a Control connection returns unsupported_transport before any I/O, because it cannot kill what it is attached to. A kill command prints nothing, so a completed result has the value :ok.

Optional session context checks physical membership at tmux's command resolution. It does not bind a particular WindowLink index when a window has multiple links in that session. WindowLink references are rejected. See LibTmux.Pane.split/3, LibTmux.Pane.send_text/4 and LibTmux.Window.rename/4 for caller examples.

Summary

Types

Explicitly selected one-shot descriptor or pinned qualified connection.

Detached creation on an existing server; default command/shell and directory unless supplied.

A created native ID without a bound reference; capture a new observation before another targeted action.

An API refusal, unsuccessful outcome or managed execution error retaining recovery context.

A 1..600000ms execution budget, default 5000ms; optional exact session context for physical targets.

A completed action's value and original transport evidence.

A failed, skipped or unknown action outcome retained inside CompletionError.

Types

connection()

@type connection() :: LibTmux.Server.t() | LibTmux.Control.t()

Explicitly selected one-shot descriptor or pinned qualified connection.

creation_option()

@type creation_option() ::
  {:timeout, 1..600_000}
  | {:cwd, binary()}
  | {:command, :default | {:shell, binary()} | {:argv, [binary(), ...]}}

Detached creation on an existing server; default command/shell and directory unless supplied.

creation_value()

@type creation_value() :: %{id: String.t(), ref: nil}

A created native ID without a bound reference; capture a new observation before another targeted action.

error()

An API refusal, unsuccessful outcome or managed execution error retaining recovery context.

option()

@type option() :: {:timeout, 1..600_000} | {:session, LibTmux.Ref.t()}

A 1..600000ms execution budget, default 5000ms; optional exact session context for physical targets.

result(value)

@type result(value) :: %{
  outcome: :completed,
  certainty: LibTmux.Error.certainty(),
  evidence: atom(),
  transport: :one_shot | :control,
  value: value,
  details: map()
}

A completed action's value and original transport evidence.

Only completed results appear in an action's {:ok, result} tuple. Command acknowledgement remains distinct from external program completion.

A completed split carries LibTmux.Pane.split_value/0. See LibTmux.Pane.split/3 for its identity and lifetime limits.

unsuccessful_result()

@type unsuccessful_result() :: %{
  outcome: :failed | :skipped | :unknown,
  certainty: LibTmux.Error.certainty(),
  evidence: atom(),
  transport: :one_shot | :control,
  value: nil,
  details: map()
}

A failed, skipped or unknown action outcome retained inside CompletionError.