Skip to main content

TmuxSessionBuilder

Struct TmuxSessionBuilder 

Source
pub struct TmuxSessionBuilder { /* private fields */ }
Expand description

Builder that accumulates tmux operations for creating and configuring a session.

Can either execute operations against a live tmux server or return them as command strings for testing and dry-run.

§Examples

use git_paw::tmux::{TmuxSessionBuilder, PaneSpec};

let session = TmuxSessionBuilder::new("my-project")
    .add_pane(PaneSpec {
        branch: "feat/auth".into(),
        worktree: "/tmp/my-project-feat-auth".into(),
        cli_command: "claude".into(),
    })
    .mouse_mode(true)
    .build()?;

// Dry-run: inspect commands
for cmd in session.command_strings() {
    println!("{cmd}");
}

// Or execute for real
session.execute()?;

Implementations§

Source§

impl TmuxSessionBuilder

Source

pub fn new(project_name: &str) -> Self

Create a new builder for the given project name.

The session will be named paw-<project_name> unless overridden with session_name.

Source

pub fn session_name(self, name: String) -> Self

Override the session name instead of deriving it from the project name.

Use this with resolve_session_name to handle name collisions.

Source

pub fn add_pane(self, spec: PaneSpec) -> Self

Add a pane that will cd into the worktree and run the CLI command.

Source

pub fn mouse_mode(self, enabled: bool) -> Self

Enable or disable mouse mode for the session (default: true).

When enabled, users can click to switch panes, drag borders to resize, and scroll. This is set per-session and does not affect other tmux sessions.

Source

pub fn build(self) -> Result<TmuxSession, PawError>

Build the full sequence of tmux commands without executing anything.

Returns a TmuxSession that can be executed or inspected. Returns an error if no panes have been added.

Trait Implementations§

Source§

impl Debug for TmuxSessionBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.