[][src]Struct seahorse::Context

pub struct Context {
    pub args: Vec<String>,
    // some fields omitted
}

Context type

This type is used only for Action arguments

Fields

args: Vec<String>

Vec<String> with flags and flag values ​​removed from command line arguments

Implementations

impl Context[src]

pub fn new(
    args: Vec<String>,
    flags: Option<Vec<Flag>>,
    help_text: String
) -> Self
[src]

Create new instance of Context Parse processing using Vec<String> command line argument and Vec<Flag> as arguments

pub fn bool_flag(&self, name: &str) -> bool[src]

Get bool flag

Example

use seahorse::Context;

fn action(c: &Context) {
    if c.bool_flag("bool") {
        println!("True!");
    } else {
        println!("False!");
    }
}

pub fn string_flag(&self, name: &str) -> Result<String, FlagError>[src]

Get string flag

Example

use seahorse::Context;

fn action(c: &Context) {
    match c.string_flag("string") {
        Ok(s) => println!("{}", s),
        Err(e) => println!("{}", e)
    }
}

pub fn int_flag(&self, name: &str) -> Result<isize, FlagError>[src]

Get int flag

Example

use seahorse::Context;

fn action(c: &Context) {
    match c.int_flag("int") {
        Ok(i) => println!("{}", i),
        Err(e) => println!("{}", e)
    }
}

pub fn float_flag(&self, name: &str) -> Result<f64, FlagError>[src]

Get float flag

Example

use seahorse::Context;

fn action(c: &Context) {
    match c.float_flag("float") {
        Ok(f) => println!("{}", f),
        Err(e) => println!("{}", e)
    }
}

pub fn help(&self)[src]

Display help

Example

use seahorse::Context;

fn action(c: &Context) {
    c.help();
}

Auto Trait Implementations

impl RefUnwindSafe for Context

impl Send for Context

impl Sync for Context

impl Unpin for Context

impl UnwindSafe for Context

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.