Skip to main content

CommandParser

Struct CommandParser 

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

A reusable parser with parse-time expansion context.

Implementations§

Source§

impl CommandParser

Source

pub fn new() -> Self

Creates a parser with no environment, tilde, or user alias overrides.

Source

pub fn with_environment_value( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Adds one variable to the parse-time environment expansion context.

Source

pub fn with_format_value( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Adds one parse-time format variable used by %if condition expansion.

Source

pub fn with_environment_store(self, environment: &EnvironmentStore) -> Self

Copies global values from an RMUX environment store into the parser.

Source

pub fn with_home_dir(self, home_dir: impl Into<String>) -> Self

Adds the fallback home directory used for ~ expansion.

Source

pub fn with_user_home_dir( self, user: impl Into<String>, home_dir: impl Into<String>, ) -> Self

Adds a deterministic ~user expansion mapping.

Source

pub fn with_command_alias( self, definition: impl Into<String>, ) -> Result<Self, CommandParseError>

Adds one command-alias option entry of the form name=value.

Source

pub fn with_command_aliases<I, S>(self, definitions: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Replaces the parser alias table with valid command-alias entries.

Source

pub fn with_exact_commands(self, commands: &'static [CommandEntry]) -> Self

Adds exact-only command names to this parser.

These entries are intentionally excluded from tmux-style prefix lookup. Use this for client-side RMUX extensions; server-side source-file parsing should keep the frozen tmux command table.

Source

pub fn with_max_command_bytes(self, max_command_bytes: usize) -> Self

Overrides the maximum parsed command size.

Source

pub fn parse(&self, input: &str) -> Result<ParsedCommands, CommandParseError>

Parses a tmux command string through the tmux-style lexer.

Source

pub fn parse_one_group( &self, input: &str, ) -> Result<ParsedCommands, CommandParseError>

Parses a tmux command string with CMD_PARSE_ONEGROUP semantics.

tmux uses this mode when a command string is parsed from an argument or option value, so embedded newlines do not create independent abort groups.

Source

pub fn parse_arguments<I, S>( &self, arguments: I, ) -> Result<ParsedCommands, CommandParseError>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Parses an argv-style tmux command vector.

tmux treats these arguments as already split and only divides commands on unescaped trailing semicolons.

Trait Implementations§

Source§

impl Clone for CommandParser

Source§

fn clone(&self) -> CommandParser

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommandParser

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CommandParser

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.