pub struct Context {
    pub args: Vec<String>,
    /* private fields */
}
Expand description

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

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

Get bool flag

Example

use seahorse::Context;

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

Get string flag

Example

use seahorse::Context;

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

Get int flag

Example

use seahorse::Context;

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

Get float flag

Example

use seahorse::Context;

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

Display help

Example

use seahorse::Context;

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.