[][src]Struct slaps::Slaps

pub struct Slaps<'a, 'b> { /* fields omitted */ }

Interactive shell mode using a clap/structopt configuration.

Implementations

impl<'a, 'b> Slaps<'a, 'b>[src]

#[must_use]pub fn with_name(name: &str) -> Self[src]

Creates a new interactive app using the default configuration.

Examples

use slaps::Slaps;

let slaps = Slaps::with_name("slaps");

#[must_use]pub fn with_name_and_config(name: &str, config: Config<'b>) -> Slaps<'a, 'b>[src]

Creates a new interactive app with the given Config.

Examples

use slaps::{Config, ColorMode, Slaps};

let slaps = Slaps::with_name_and_config("slaps", Config::default()
    .color_mode(ColorMode::Disabled));

#[must_use]pub fn subcommand<T: 'b>(self, command: App<'a, 'b>, handler: T) -> Self where
    T: Fn(&ArgMatches) -> Result<(), ExecutionError> + Send + Sync
[src]

Registers a Clap subcommand configuration with Slaps.

Examples

use clap::App;
use slaps::Slaps;

let slaps = Slaps::with_name("slaps")
    .subcommand(App::new("slap"), |matches| {println!("{:?}", matches); Ok(())} );

pub fn prompt_line(&self, prompt: Option<&str>) -> Result<String, ReadlineError>[src]

Prompts the user for a String using the default prompt.

If prompt is None, uses the default from the Config.

Errors

May return a ReadlineError from the internal readline implementation.

pub fn prompt_password(
    &self,
    prompt: Option<&str>
) -> Result<String, ReadlineError>
[src]

Prompts the user for a password.

If prompt is None, uses the default from the Config.

Errors

May return a ReadlineError from the internal readline implementation.

pub fn get_matches<T: AsRef<str>>(
    &mut self,
    input: T
) -> Result<ArgMatches, Error>
[src]

Parses a string directly into a clap::ArgMatches object.

Errors

  • MismatchedQuote parsing failed due to mismatched quotation marks within the input.

Examples

use clap::{App, Arg};
use slaps::Slaps;

let command = App::new("slaps").arg(Arg::with_name("that").long("that").takes_value(true));
let mut slaps = Slaps::with_name("slaps").subcommand(command, |args| Ok(()));
let matches = slaps.get_matches("slaps --that arg").unwrap();

assert_eq!(matches.subcommand_name(), Some("slaps"));
assert_eq!(matches.subcommand_matches("slaps").unwrap().value_of("that"), Some("arg"));

pub fn run(self) -> Result<(), Error>[src]

Starts the main interactive loop, prompting the user for input repeatedly.

Errors

Will return an error when it fails to read more input.

Trait Implementations

impl<'a, 'b> Debug for Slaps<'a, 'b>[src]

Auto Trait Implementations

impl<'a, 'b> !RefUnwindSafe for Slaps<'a, 'b>

impl<'a, 'b> !Send for Slaps<'a, 'b>

impl<'a, 'b> !Sync for Slaps<'a, 'b>

impl<'a, 'b> Unpin for Slaps<'a, 'b>

impl<'a, 'b> !UnwindSafe for Slaps<'a, 'b>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.