Skip to main content

ShellBuilder

Struct ShellBuilder 

Source
pub struct ShellBuilder<SE: ShellExtensions = DefaultShellExtensions, S: State = Empty> { /* private fields */ }
Expand description

Builder for Shell

Implementations§

Source§

impl<SE: ShellExtensions, S: IsComplete> ShellBuilder<SE, S>

Source

pub async fn build(self) -> Result<Shell<SE>, Error>

Returns a new shell instance created with the options provided. Runs any configuration loading as well.

Source§

impl<SE: ShellExtensions, S: State> ShellBuilder<SE, S>

Source

pub fn disable_option(self, option: impl Into<String>) -> Self

Add a disabled option

Source

pub fn enable_option(self, option: impl Into<String>) -> Self

Add an enabled option

Source

pub fn disable_options( self, options: impl IntoIterator<Item: Into<String>>, ) -> Self

Add many disabled options

Source

pub fn enable_options( self, options: impl IntoIterator<Item: Into<String>>, ) -> Self

Add many enabled options

Source

pub fn disable_shopt_option(self, option: impl Into<String>) -> Self

Add a disabled shopt option

Source

pub fn enable_shopt_option(self, option: impl Into<String>) -> Self

Add an enabled shopt option

Source

pub fn disable_shopt_options( self, options: impl IntoIterator<Item: Into<String>>, ) -> Self

Add many disabled shopt options

Source

pub fn enable_shopt_options( self, options: impl IntoIterator<Item: Into<String>>, ) -> Self

Add many enabled shopt options

Source

pub fn builtin(self, name: impl Into<String>, reg: Registration<SE>) -> Self

Add a single builtin registration

Source

pub fn builtins( self, builtins: impl IntoIterator<Item = (String, Registration<SE>)>, ) -> Self

Add many builtin registrations

Source

pub fn var(self, name: impl Into<String>, variable: ShellVariable) -> Self

Adds a single variable to be initialized in the shell.

Source§

impl<SE: ShellExtensions, S: State> ShellBuilder<SE, S>

Source

pub fn error_formatter( self, value: SE::ErrorFormatter, ) -> ShellBuilder<SE, SetErrorFormatter<S>>
where S::ErrorFormatter: IsUnset,

Optional (Some / Option setters). Default: <SE::ErrorFormatter as Default>::default().

Error behavior implementation.

Source

pub fn maybe_error_formatter( self, value: Option<SE::ErrorFormatter>, ) -> ShellBuilder<SE, SetErrorFormatter<S>>
where S::ErrorFormatter: IsUnset,

Optional (Some / Option setters). Default: <SE::ErrorFormatter as Default>::default().

Error behavior implementation.

Source

pub fn disallow_overwriting_regular_files_via_output_redirection( self, value: bool, ) -> ShellBuilder<SE, SetDisallowOverwritingRegularFilesViaOutputRedirection<S>>

Optional (Some / Option setters). Default: false.

Disallow overwriting regular files via output redirection.

Source

pub fn maybe_disallow_overwriting_regular_files_via_output_redirection( self, value: Option<bool>, ) -> ShellBuilder<SE, SetDisallowOverwritingRegularFilesViaOutputRedirection<S>>

Optional (Some / Option setters). Default: false.

Disallow overwriting regular files via output redirection.

Source

pub fn do_not_execute_commands( self, value: bool, ) -> ShellBuilder<SE, SetDoNotExecuteCommands<S>>
where S::DoNotExecuteCommands: IsUnset,

Optional (Some / Option setters). Default: false.

Do not execute commands.

Source

pub fn maybe_do_not_execute_commands( self, value: Option<bool>, ) -> ShellBuilder<SE, SetDoNotExecuteCommands<S>>
where S::DoNotExecuteCommands: IsUnset,

Optional (Some / Option setters). Default: false.

Do not execute commands.

Source

pub fn exit_after_one_command( self, value: bool, ) -> ShellBuilder<SE, SetExitAfterOneCommand<S>>
where S::ExitAfterOneCommand: IsUnset,

Optional (Some / Option setters). Default: false.

Exit after one command.

Source

pub fn maybe_exit_after_one_command( self, value: Option<bool>, ) -> ShellBuilder<SE, SetExitAfterOneCommand<S>>
where S::ExitAfterOneCommand: IsUnset,

Optional (Some / Option setters). Default: false.

Exit after one command.

Source

pub fn interactive(self, value: bool) -> ShellBuilder<SE, SetInteractive<S>>
where S::Interactive: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is interactive.

Source

pub fn maybe_interactive( self, value: Option<bool>, ) -> ShellBuilder<SE, SetInteractive<S>>
where S::Interactive: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is interactive.

Source

pub fn login(self, value: bool) -> ShellBuilder<SE, SetLogin<S>>
where S::Login: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is a login shell.

Source

pub fn maybe_login(self, value: Option<bool>) -> ShellBuilder<SE, SetLogin<S>>
where S::Login: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is a login shell.

Source

pub fn no_editing(self, value: bool) -> ShellBuilder<SE, SetNoEditing<S>>
where S::NoEditing: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to skip using a readline-like interface for input.

Source

pub fn maybe_no_editing( self, value: Option<bool>, ) -> ShellBuilder<SE, SetNoEditing<S>>
where S::NoEditing: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to skip using a readline-like interface for input.

Source

pub fn profile( self, value: ProfileLoadBehavior, ) -> ShellBuilder<SE, SetProfile<S>>
where S::Profile: IsUnset,

Optional (Some / Option setters). Default: <ProfileLoadBehavior as Default>::default().

System profile loading behavior.

Source

pub fn maybe_profile( self, value: Option<ProfileLoadBehavior>, ) -> ShellBuilder<SE, SetProfile<S>>
where S::Profile: IsUnset,

Optional (Some / Option setters). Default: <ProfileLoadBehavior as Default>::default().

System profile loading behavior.

Source

pub fn rc(self, value: RcLoadBehavior) -> ShellBuilder<SE, SetRc<S>>
where S::Rc: IsUnset,

Optional (Some / Option setters). Default: <RcLoadBehavior as Default>::default().

Rc file loading behavior.

Source

pub fn maybe_rc( self, value: Option<RcLoadBehavior>, ) -> ShellBuilder<SE, SetRc<S>>
where S::Rc: IsUnset,

Optional (Some / Option setters). Default: <RcLoadBehavior as Default>::default().

Rc file loading behavior.

Source

pub fn do_not_inherit_env( self, value: bool, ) -> ShellBuilder<SE, SetDoNotInheritEnv<S>>
where S::DoNotInheritEnv: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to skip inheriting environment variables from the calling process.

Source

pub fn maybe_do_not_inherit_env( self, value: Option<bool>, ) -> ShellBuilder<SE, SetDoNotInheritEnv<S>>
where S::DoNotInheritEnv: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to skip inheriting environment variables from the calling process.

Source

pub fn skip_well_known_vars( self, value: bool, ) -> ShellBuilder<SE, SetSkipWellKnownVars<S>>
where S::SkipWellKnownVars: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to skip initializing well-known variables.

Source

pub fn maybe_skip_well_known_vars( self, value: Option<bool>, ) -> ShellBuilder<SE, SetSkipWellKnownVars<S>>
where S::SkipWellKnownVars: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to skip initializing well-known variables.

Source

pub fn fds( self, value: HashMap<ShellFd, OpenFile>, ) -> ShellBuilder<SE, SetFds<S>>
where S::Fds: IsUnset,

Optional (Some / Option setters). Default: <HashMap<ShellFd, openfiles::OpenFile> as Default>::default().

Provides a set of initial open files to be tracked by the shell.

Source

pub fn maybe_fds( self, value: Option<HashMap<ShellFd, OpenFile>>, ) -> ShellBuilder<SE, SetFds<S>>
where S::Fds: IsUnset,

Optional (Some / Option setters). Default: <HashMap<ShellFd, openfiles::OpenFile> as Default>::default().

Provides a set of initial open files to be tracked by the shell.

Source

pub fn external_cmd_leads_session( self, value: bool, ) -> ShellBuilder<SE, SetExternalCmdLeadsSession<S>>
where S::ExternalCmdLeadsSession: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to launch external commands as session leaders.

Source

pub fn maybe_external_cmd_leads_session( self, value: Option<bool>, ) -> ShellBuilder<SE, SetExternalCmdLeadsSession<S>>
where S::ExternalCmdLeadsSession: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to launch external commands as session leaders.

Source

pub fn working_dir(self, value: PathBuf) -> ShellBuilder<SE, SetWorkingDir<S>>
where S::WorkingDir: IsUnset,

Optional (Some / Option setters). Initial working dir for the shell. If left unspecified, will be populated from the host environment.

Source

pub fn maybe_working_dir( self, value: Option<PathBuf>, ) -> ShellBuilder<SE, SetWorkingDir<S>>
where S::WorkingDir: IsUnset,

Optional (Some / Option setters). Initial working dir for the shell. If left unspecified, will be populated from the host environment.

Source

pub fn posix(self, value: bool) -> ShellBuilder<SE, SetPosix<S>>
where S::Posix: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is in POSIX compliance mode.

Source

pub fn maybe_posix(self, value: Option<bool>) -> ShellBuilder<SE, SetPosix<S>>
where S::Posix: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is in POSIX compliance mode.

Source

pub fn print_commands_and_arguments( self, value: bool, ) -> ShellBuilder<SE, SetPrintCommandsAndArguments<S>>
where S::PrintCommandsAndArguments: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to print commands and arguments as they are read.

Source

pub fn maybe_print_commands_and_arguments( self, value: Option<bool>, ) -> ShellBuilder<SE, SetPrintCommandsAndArguments<S>>
where S::PrintCommandsAndArguments: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to print commands and arguments as they are read.

Source

pub fn read_commands_from_stdin( self, value: bool, ) -> ShellBuilder<SE, SetReadCommandsFromStdin<S>>
where S::ReadCommandsFromStdin: IsUnset,

Optional (Some / Option setters). Default: false.

Whether commands are being read from stdin.

Source

pub fn maybe_read_commands_from_stdin( self, value: Option<bool>, ) -> ShellBuilder<SE, SetReadCommandsFromStdin<S>>
where S::ReadCommandsFromStdin: IsUnset,

Optional (Some / Option setters). Default: false.

Whether commands are being read from stdin.

Source

pub fn shell_name(self, value: String) -> ShellBuilder<SE, SetShellName<S>>
where S::ShellName: IsUnset,

Optional (Some / Option setters). The name of the shell.

Source

pub fn maybe_shell_name( self, value: Option<String>, ) -> ShellBuilder<SE, SetShellName<S>>
where S::ShellName: IsUnset,

Optional (Some / Option setters). The name of the shell.

Source

pub fn shell_args(self, value: Vec<String>) -> ShellBuilder<SE, SetShellArgs<S>>
where S::ShellArgs: IsUnset,

Optional (Some / Option setters). Base positional arguments for the shell (not including the shell name).

Source

pub fn maybe_shell_args( self, value: Option<Vec<String>>, ) -> ShellBuilder<SE, SetShellArgs<S>>
where S::ShellArgs: IsUnset,

Optional (Some / Option setters). Base positional arguments for the shell (not including the shell name).

Source

pub fn shell_product_display_str( self, value: String, ) -> ShellBuilder<SE, SetShellProductDisplayStr<S>>
where S::ShellProductDisplayStr: IsUnset,

Optional (Some / Option setters). Optionally provides a display string describing the version and variant of the shell.

Source

pub fn maybe_shell_product_display_str( self, value: Option<String>, ) -> ShellBuilder<SE, SetShellProductDisplayStr<S>>
where S::ShellProductDisplayStr: IsUnset,

Optional (Some / Option setters). Optionally provides a display string describing the version and variant of the shell.

Source

pub fn sh_mode(self, value: bool) -> ShellBuilder<SE, SetShMode<S>>
where S::ShMode: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to run in maximal POSIX sh compatibility mode.

Source

pub fn maybe_sh_mode( self, value: Option<bool>, ) -> ShellBuilder<SE, SetShMode<S>>
where S::ShMode: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to run in maximal POSIX sh compatibility mode.

Source

pub fn treat_unset_variables_as_error( self, value: bool, ) -> ShellBuilder<SE, SetTreatUnsetVariablesAsError<S>>
where S::TreatUnsetVariablesAsError: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to treat expansion of unset variables as an error.

Source

pub fn maybe_treat_unset_variables_as_error( self, value: Option<bool>, ) -> ShellBuilder<SE, SetTreatUnsetVariablesAsError<S>>
where S::TreatUnsetVariablesAsError: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to treat expansion of unset variables as an error.

Source

pub fn exit_on_nonzero_command_exit( self, value: bool, ) -> ShellBuilder<SE, SetExitOnNonzeroCommandExit<S>>
where S::ExitOnNonzeroCommandExit: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to enable error-on-exit behavior.

Source

pub fn maybe_exit_on_nonzero_command_exit( self, value: Option<bool>, ) -> ShellBuilder<SE, SetExitOnNonzeroCommandExit<S>>
where S::ExitOnNonzeroCommandExit: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to enable error-on-exit behavior.

Source

pub fn disable_pathname_expansion( self, value: bool, ) -> ShellBuilder<SE, SetDisablePathnameExpansion<S>>
where S::DisablePathnameExpansion: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to disable pathname expansion.

Source

pub fn maybe_disable_pathname_expansion( self, value: Option<bool>, ) -> ShellBuilder<SE, SetDisablePathnameExpansion<S>>
where S::DisablePathnameExpansion: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to disable pathname expansion.

Source

pub fn verbose(self, value: bool) -> ShellBuilder<SE, SetVerbose<S>>
where S::Verbose: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to print verbose output.

Source

pub fn maybe_verbose( self, value: Option<bool>, ) -> ShellBuilder<SE, SetVerbose<S>>
where S::Verbose: IsUnset,

Optional (Some / Option setters). Default: false.

Whether to print verbose output.

Source

pub fn parser(self, value: ParserImpl) -> ShellBuilder<SE, SetParser<S>>
where S::Parser: IsUnset,

Optional (Some / Option setters). Default: <crate::parser::ParserImpl as Default>::default().

Parser implementation to use.

Source

pub fn maybe_parser( self, value: Option<ParserImpl>, ) -> ShellBuilder<SE, SetParser<S>>
where S::Parser: IsUnset,

Optional (Some / Option setters). Default: <crate::parser::ParserImpl as Default>::default().

Parser implementation to use.

Source

pub fn command_string_mode( self, value: bool, ) -> ShellBuilder<SE, SetCommandStringMode<S>>
where S::CommandStringMode: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is in command string mode (-c).

Source

pub fn maybe_command_string_mode( self, value: Option<bool>, ) -> ShellBuilder<SE, SetCommandStringMode<S>>
where S::CommandStringMode: IsUnset,

Optional (Some / Option setters). Default: false.

Whether the shell is in command string mode (-c).

Source

pub fn max_function_call_depth( self, value: usize, ) -> ShellBuilder<SE, SetMaxFunctionCallDepth<S>>
where S::MaxFunctionCallDepth: IsUnset,

Optional (Some / Option setters). Maximum function call depth.

Source

pub fn maybe_max_function_call_depth( self, value: Option<usize>, ) -> ShellBuilder<SE, SetMaxFunctionCallDepth<S>>
where S::MaxFunctionCallDepth: IsUnset,

Optional (Some / Option setters). Maximum function call depth.

Source

pub fn key_bindings( self, value: Arc<Mutex<dyn KeyBindings>>, ) -> ShellBuilder<SE, SetKeyBindings<S>>
where S::KeyBindings: IsUnset,

Optional (Some / Option setters). Key bindings helper for the shell to use.

Source

pub fn maybe_key_bindings( self, value: Option<Arc<Mutex<dyn KeyBindings>>>, ) -> ShellBuilder<SE, SetKeyBindings<S>>
where S::KeyBindings: IsUnset,

Optional (Some / Option setters). Key bindings helper for the shell to use.

Source

pub fn shell_version( self, value: String, ) -> ShellBuilder<SE, SetShellVersion<S>>
where S::ShellVersion: IsUnset,

Optional (Some / Option setters). Brush implementation version.

Source

pub fn maybe_shell_version( self, value: Option<String>, ) -> ShellBuilder<SE, SetShellVersion<S>>
where S::ShellVersion: IsUnset,

Optional (Some / Option setters). Brush implementation version.

Auto Trait Implementations§

§

impl<SE, S> Freeze for ShellBuilder<SE, S>

§

impl<SE = ShellExtensionsImpl, S = Empty> !RefUnwindSafe for ShellBuilder<SE, S>

§

impl<SE, S> Send for ShellBuilder<SE, S>

§

impl<SE, S> Sync for ShellBuilder<SE, S>

§

impl<SE, S> Unpin for ShellBuilder<SE, S>

§

impl<SE, S> UnsafeUnpin for ShellBuilder<SE, S>

§

impl<SE = ShellExtensionsImpl, S = Empty> !UnwindSafe for ShellBuilder<SE, S>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more