Shell

Struct Shell 

Source
pub struct Shell<C, R, A: Parser + Command<C, R>> { /* private fields */ }
Expand description

A command that spawns a shell of the provided dispatcher type.

The shell command spawns a shell using rustyline and shellwords libraries. The type arguments it takes are straightforward:

  • Context type (state)
  • Return type (same as command hierarchy)
  • Dispatcher to create a shell for (can be self-referential)

This object is only built if you set the shell feature while importing:

clishe = { version = "^0", features = ["shell"] }

§Example

dispatchers! {
    Food(self, _: &mut u64) -> Result<()> [
        Shell: clishe::Shell<u64, (), Food>,
    ],
}

Trait Implementations§

Source§

impl<C, R, A> Args for Shell<C, R, A>
where A: Parser + Command<C, R>,

Source§

fn augment_args<'b>(cmd: Command<'b>) -> Command<'b>

Append to Command so it can instantiate Self. Read more
Source§

fn augment_args_for_update<'b>(cmd: Command<'b>) -> Command<'b>

Append to Command so it can update self. Read more
Source§

impl<C, R, A> Command<C, R> for Shell<C, R, A>
where A: Parser + Command<C, R>,

Source§

fn run(self, ctx: &mut C) -> Result<R>

Source§

impl<C, R, A> CommandFactory for Shell<C, R, A>
where A: Parser + Command<C, R>,

Source§

fn into_app<'b>() -> App<'b>

Deprecated, replaced with CommandFactory::command
Source§

fn into_app_for_update<'b>() -> App<'b>

Deprecated, replaced with CommandFactory::command_for_update
Source§

fn command<'help>() -> App<'help>

Build a Command that can instantiate Self. Read more
Source§

fn command_for_update<'help>() -> App<'help>

Build a Command that can update self. Read more
Source§

impl<C, R, A> FromArgMatches for Shell<C, R, A>
where A: Parser + Command<C, R>,

Source§

fn from_arg_matches(_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, _matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches_mut( &mut self, matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl<C, R, A> Parser for Shell<C, R, A>
where A: Parser + Command<C, R>,

Source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error
Source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
Source§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error
Source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
Source§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error
Source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

Auto Trait Implementations§

§

impl<C, R, A> Freeze for Shell<C, R, A>

§

impl<C, R, A> RefUnwindSafe for Shell<C, R, A>

§

impl<C, R, A> Send for Shell<C, R, A>
where A: Send, C: Send, R: Send,

§

impl<C, R, A> Sync for Shell<C, R, A>
where A: Sync, C: Sync, R: Sync,

§

impl<C, R, A> Unpin for Shell<C, R, A>
where A: Unpin, C: Unpin, R: Unpin,

§

impl<C, R, A> UnwindSafe for Shell<C, R, A>
where A: UnwindSafe, C: UnwindSafe, R: UnwindSafe,

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.