command.CommandChain
Rust
- Python Unavailable
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- command
- Package
- libtmux
- Source
- crates/libtmux/src/command.rs
-
Several tmux commands dispatched as one
tmux a \; binvocation.tmux reads a bare
;argv element as a command boundary and a\;element as a literal semicolon.Commandlowers every trailing;a caller supplies, so a boundary cannot come from an argument; it comes from this type, which owns the separator. That is what makes a chain safe to build from untrusted values.A chain is one dispatch: one process, one exit status, one merged stdout. tmux runs the sequence up to the first failure and drops the remainder, and the merged result is the same whichever member failed, so a chain reports one outcome rather than one per command. Use it to cut round trips when the commands succeed or fail as a unit; dispatch separately when you need to know which one failed.
Examples
use libtmux::{Command, CommandChain};let chain = CommandChain::new(Command::new("send-keys").arg("-t").arg("%1")).then(Command::new("rename-window").arg("-t").arg("@1").arg("edit"));assert_eq!(chain.command_count(), 2);assert_eq!(chain.summary().to_string(),r#""send-keys" "-t" "%1" ; "rename-window" "-t" "@1" "edit""#,);A literal semicolon stays an argument, and renders quoted so it is not mistaken for the boundary beside it:
use libtmux::{Command, CommandChain};let chain = CommandChain::new(Command::new("display-message").arg(";")).then(Command::new("list-sessions"));assert_eq!(chain.summary().to_string(),r#""display-message" ";" ; "list-sessions""#,);
4 declared, 0 inherited
Members
- command_count method Return the number of commands in the chain, always at least one.
- new method Start a chain from its first command.
- summary method Build a bounded, sanitized summary of the whole chain.
- then method Append one command, to run after the previous one succeeds.