clap 1.4.2

A simple to use, efficient, and full featured Command Line Argument Parser
Documentation
use std::fmt::{Display, Formatter, Result};
use std::result::Result as StdResult;
use std::rc::Rc;

pub struct PosBuilder<'n> {
    pub name: &'n str,
    /// The string of text that will displayed to the user when the application's
    /// `help` text is displayed
    pub help: Option<&'n str>,
    /// If this is a required by default when using the command line program
    /// i.e. a configuration file that's required for the program to function
    /// **NOTE:** required by default means, it is required *until* mutually
    /// exclusive arguments are evaluated.
    pub required: bool,
    /// Allow multiple occurrences of an option argument such as "-c some -c other"
    pub multiple: bool,
    /// A list of names of other arguments that are *required* to be used when
    /// this flag is used
    pub requires: Option<Vec<&'n str>>,
    /// A list of names for other arguments that *may not* be used with this flag
    pub blacklist: Option<Vec<&'n str>>,
    /// A list of possible values for this argument
    pub possible_vals: Option<Vec<&'n str>>,
    /// The index of the argument
    pub index: u8,
    pub num_vals: Option<u8>,
    pub max_vals: Option<u8>,
    pub min_vals: Option<u8>,
    pub empty_vals: bool,
    pub global: bool,
    pub validator: Option<Rc<Fn(String) -> StdResult<(), String>>>,
    /// A list of names for other arguments that *mutually override* this flag
    pub overrides: Option<Vec<&'n str>>,
    pub hidden: bool
}

impl<'n> Display for PosBuilder<'n> {
    fn fmt(&self,
           f: &mut Formatter) 
           -> Result {
        if self.required {
            try!(write!(f, "<{}>", self.name));
        } else {
            try!(write!(f, "[{}]", self.name));
        }
        if self.multiple {
            try!(write!(f, "..."));
        }

        Ok(())
    }
}
#[cfg(test)]
mod test {
    use super::PosBuilder;

    #[test]
    fn posbuilder_display() {
        let p = PosBuilder {
            name: "pos",
            help: None,
            multiple: true,
            blacklist: None,
            required: false,
            possible_vals: None,
            requires: None,
            num_vals: None,
            min_vals: None,
            max_vals: None,
            index: 1,
            empty_vals: true,
            global: false,
            validator: None,
            overrides: None,
            hidden: false,
        };

        assert_eq!(&*format!("{}", p), "[pos]...");

        let p2 = PosBuilder {
            name: "pos",
            help: None,
            multiple: false,
            blacklist: None,
            required: true,
            possible_vals: None,
            requires: None,
            num_vals: None,
            min_vals: None,
            max_vals: None,
            index: 1,
            empty_vals: true,
            global: false,
            validator: None,
            overrides: None,
            hidden: false,
        };

        assert_eq!(&*format!("{}", p2), "<pos>");
    }
}