pub struct DefaultRepl<C>{ /* private fields */ }
Expand description
Default implementation for a REPL
Note that you need to define the commands by yourself with a Subcommands enum.
§Example
use libpt_cli::repl::{DefaultRepl, Repl};
use clap::Subcommand;
use strum::EnumIter;
#[derive(Subcommand, Debug, EnumIter, Clone)]
enum ReplCommand {
/// hello world
Hello,
/// leave the repl
Exit,
}
fn main() {
let mut repl = DefaultRepl::<ReplCommand>::default();
loop {
repl.step().unwrap();
match repl.command().to_owned().unwrap() {
ReplCommand::Hello => println!("Hello"),
ReplCommand::Exit => break,
_ => (),
}
}
}
Screenshot
Trait Implementations§
Source§impl<C> Args for DefaultRepl<C>
impl<C> Args for DefaultRepl<C>
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Append to
Command
so it can instantiate self
via
FromArgMatches::update_from_arg_matches_mut
Read moreSource§impl<C> CommandFactory for DefaultRepl<C>
impl<C> CommandFactory for DefaultRepl<C>
Source§impl<C> Debug for DefaultRepl<C>
impl<C> Debug for DefaultRepl<C>
Source§impl<C> Default for DefaultRepl<C>
impl<C> Default for DefaultRepl<C>
Source§impl<C> FromArgMatches for DefaultRepl<C>
impl<C> FromArgMatches for DefaultRepl<C>
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Source§impl<C> Parser for DefaultRepl<C>
impl<C> Parser for DefaultRepl<C>
Source§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
Parse from iterator, exit on error.
Source§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
Parse from iterator, return Err on error.
Source§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
Source§impl<C> Repl<C> for DefaultRepl<C>
impl<C> Repl<C> for DefaultRepl<C>
Auto Trait Implementations§
impl<C> Freeze for DefaultRepl<C>where
C: Freeze,
impl<C> RefUnwindSafe for DefaultRepl<C>where
C: RefUnwindSafe,
impl<C> Send for DefaultRepl<C>where
C: Send,
impl<C> Sync for DefaultRepl<C>where
C: Sync,
impl<C> Unpin for DefaultRepl<C>where
C: Unpin,
impl<C> UnwindSafe for DefaultRepl<C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more