[][src]Struct easy_flag::FlagSet

pub struct FlagSet<'a> { /* fields omitted */ }

Represents a set of defined flags.

Methods

impl<'a> FlagSet<'a>[src]

pub fn new(name: &str) -> Self[src]

Constructs a new FlagSet instance. The name will be added to the usage information.

Examples

 let set = FlagSet::new("my set")

pub fn add(self, name: &'a str, var: &'a mut dyn Any, help: &'a str) -> Self[src]

Adds a new flag to the FlagSet

The function itself determines the type of flag. The standard types are supported: bool, f32, f64, i8, i16, i32, i128, isize, u8, u16, u32, u128, usize, String.

WARNING: Unsupported type will cause panic.

Examples

 let mut f = String::from("default value");
 FlagSet::new("my set").add("-f, --flag", &mut f, "flag `example`")

pub fn parse(&mut self, args: &[String]) -> Result<(), String>[src]

Parsing args.

Examples

 let mut f = String::from("default value");
 let args: Vec<String> = std::env::args().collect();
 FlagSet::new(&args[0])
                .add("-f, --flag", &mut f, "flag `example`")
                .parse(&args[1..])
                .unwrap()

pub fn name(&self) -> &str[src]

Gets flag set name.

pub fn usage(&self) -> String[src]

Formats a usage message with set name.

pub fn defaults(&self) -> String[src]

Formats a flag list message.

Trait Implementations

impl<'a> Debug for FlagSet<'a>[src]

Auto Trait Implementations

impl<'a> Send for FlagSet<'a>

impl<'a> Sync for FlagSet<'a>

impl<'a> Unpin for FlagSet<'a>

impl<'a> !UnwindSafe for FlagSet<'a>

impl<'a> RefUnwindSafe for FlagSet<'a>

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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