Struct portable_pty::cmdbuilder::CommandBuilder
source · pub struct CommandBuilder { /* private fields */ }
Expand description
CommandBuilder
is used to prepare a command to be spawned into a pty.
The interface is intentionally similar to that of std::process::Command
.
Implementations§
source§impl CommandBuilder
impl CommandBuilder
sourcepub fn new<S: AsRef<OsStr>>(program: S) -> Self
pub fn new<S: AsRef<OsStr>>(program: S) -> Self
Create a new builder instance with argv[0] set to the specified program.
sourcepub fn from_argv(args: Vec<OsString>) -> Self
pub fn from_argv(args: Vec<OsString>) -> Self
Create a new builder instance from a pre-built argument vector
sourcepub fn set_controlling_tty(&mut self, controlling_tty: bool)
pub fn set_controlling_tty(&mut self, controlling_tty: bool)
Set whether we should set the pty as the controlling terminal. The default is true, which is usually what you want, but you may need to set this to false if you are crossing container boundaries (eg: flatpak) to workaround issues like: https://github.com/flatpak/flatpak/issues/3697 https://github.com/flatpak/flatpak/issues/3285
pub fn get_controlling_tty(&self) -> bool
sourcepub fn new_default_prog() -> Self
pub fn new_default_prog() -> Self
Create a new builder instance that will run some idea of a default
program. Such a builder will panic if arg
is called on it.
sourcepub fn is_default_prog(&self) -> bool
pub fn is_default_prog(&self) -> bool
Returns true if this builder was created via new_default_prog
sourcepub fn arg<S: AsRef<OsStr>>(&mut self, arg: S)
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S)
Append an argument to the current command line.
Will panic if called on a builder created via new_default_prog
.
sourcepub fn args<I, S>(&mut self, args: I)where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
pub fn args<I, S>(&mut self, args: I)where I: IntoIterator<Item = S>, S: AsRef<OsStr>,
Append a sequence of arguments to the current command line
pub fn get_argv(&self) -> &Vec<OsString>
pub fn get_argv_mut(&mut self) -> &mut Vec<OsString>
sourcepub fn env<K, V>(&mut self, key: K, value: V)where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
pub fn env<K, V>(&mut self, key: K, value: V)where K: AsRef<OsStr>, V: AsRef<OsStr>,
Override the value of an environmental variable
pub fn env_remove<K>(&mut self, key: K)where K: AsRef<OsStr>,
pub fn env_clear(&mut self)
pub fn get_env<K>(&self, key: K) -> Option<&OsStr>where K: AsRef<OsStr>,
pub fn cwd<D>(&mut self, dir: D)where D: AsRef<OsStr>,
pub fn clear_cwd(&mut self)
pub fn get_cwd(&self) -> Option<&OsString>
sourcepub fn iter_extra_env_as_str(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter_extra_env_as_str(&self) -> impl Iterator<Item = (&str, &str)>
Iterate over the configured environment. Only includes environment
variables set by the caller via env
, not variables set in the base
environment.
pub fn iter_full_env_as_str(&self) -> impl Iterator<Item = (&str, &str)>
sourcepub fn as_unix_command_line(&self) -> Result<String>
pub fn as_unix_command_line(&self) -> Result<String>
Return the configured command and arguments as a single string, quoted per the unix shell conventions.
Trait Implementations§
source§impl Clone for CommandBuilder
impl Clone for CommandBuilder
source§fn clone(&self) -> CommandBuilder
fn clone(&self) -> CommandBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CommandBuilder
impl Debug for CommandBuilder
source§impl PartialEq<CommandBuilder> for CommandBuilder
impl PartialEq<CommandBuilder> for CommandBuilder
source§fn eq(&self, other: &CommandBuilder) -> bool
fn eq(&self, other: &CommandBuilder) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for CommandBuilder
Auto Trait Implementations§
impl RefUnwindSafe for CommandBuilder
impl Send for CommandBuilder
impl Sync for CommandBuilder
impl Unpin for CommandBuilder
impl UnwindSafe for CommandBuilder
Blanket Implementations§
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.