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
sourceimpl Context
impl Context
sourcepub fn new(
args: Vec<String>,
flags: Option<Vec<Flag>>,
help_text: String
) -> Self
pub fn new(
args: Vec<String>,
flags: Option<Vec<Flag>>,
help_text: String
) -> Self
Create new instance of Context
Parse processing using Vec<String>
command line argument and Vec<Flag>
as arguments
sourcepub fn bool_flag(&self, name: &str) -> bool
pub fn bool_flag(&self, name: &str) -> bool
Get bool flag
Example
use seahorse::Context;
fn action(c: &Context) {
if c.bool_flag("bool") {
println!("True!");
} else {
println!("False!");
}
}
sourcepub fn string_flag(&self, name: &str) -> Result<String, FlagError>
pub fn string_flag(&self, name: &str) -> Result<String, FlagError>
Get string flag
Example
use seahorse::Context;
fn action(c: &Context) {
match c.string_flag("string") {
Ok(s) => println!("{}", s),
Err(e) => println!("{}", e)
}
}
sourcepub fn int_flag(&self, name: &str) -> Result<isize, FlagError>
pub fn int_flag(&self, name: &str) -> Result<isize, FlagError>
Get int flag
Example
use seahorse::Context;
fn action(c: &Context) {
match c.int_flag("int") {
Ok(i) => println!("{}", i),
Err(e) => println!("{}", e)
}
}
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more