pub fn new(matches: clap::ArgMatches) -> Result<Options> {
        let (delete, info, list, save) = (
            matches.is_present("delete"),
            matches.is_present("info"),
            matches.is_present("list"),
            matches.is_present("save"),
        );

        let action = match (delete, info, list, save) {
            (true, _, _, _) => Action::Delete,
            (_, true, _, _) => Action::Info,
            (_, _, true, _) => Action::List,
            (_, _, _, true) => Action::Save,
            _ => Action::Pathname,
        };

        let directory = matches.value_of("DIRECTORY").map(PathBuf::from);
        let path = match directory {
            Some(value) => try!(dir::resolve(value)),
            None => env::current_dir().map_err(Error::io)?,
        };

        let name = matches
            .value_of("NAME")
            .map(normalize)
            .unwrap_or(try!(dir::basename(&path)));

        let config = config(matches.value_of("config"))?;

        Ok(Options {
            action: action,
            config: config,
            path: path,
            initialize: matches.is_present("initialize"),
            name: name,
            verbose: matches.is_present("verbose"),
        })
    }
/// Creates a new instance of Options from clap::ArgMatches.
///
/// # Examples:
///
/// ```
/// use to::cli;
///
/// let matches = cli::app().get_matches_from(vec![""]);
/// let options = cli::Options::new(matches).unwrap();
///
/// assert_eq!(options.verbose, false);
/// assert_eq!(options.initialize, false);
/// assert_eq!(options.action, cli::Action::Pathname);
/// ```
Creates a new instance of Options from clap::ArgMatches.
Creates a new instance of Options from clap :: ArgMatches .
pub fn new(matches: clap::ArgMatches) -> Result<Options> {
        let (delete, info, list, save) = (
            matches.is_present("delete"),
            matches.is_present("info"),
            matches.is_present("list"),
            matches.is_present("save"),
        );
        let action = match (delete, info, list, save) {
            (true, _, _, _) => Action::Delete,
            (_, true, _, _) => Action::Info,
            (_, _, true, _) => Action::List,
            (_, _, _, true) => Action::Save,
            _ => Action::Pathname,
        };
        let directory = matches.value_of("DIRECTORY").map(PathBuf::from);
        let path = match directory {
            Some(value) => try!(dir::resolve(value)),
            None => env::current_dir().map_err(Error::io)?,
        };
        let name = matches
            .value_of("NAME")
            .map(normalize)
            .unwrap_or(try!(dir::basename(&path)));
        let config = config(matches.value_of("config"))?;
        Ok(Options {
            action: action,
            config: config,
            path: path,
            initialize: matches.is_present("initialize"),
            name: name,
            verbose: matches.is_present("verbose"),
        })
    }
pub fn new ( matches : clap :: ArgMatches ) -> Result < Options > { let ( delete , info , list , save ) = ( matches . is_present ( " " ) , matches . is_present ( " " ) , matches . is_present ( " " ) , matches . is_present ( " " ) , ) ; let action = match ( delete , info , list , save ) { ( true , _ , _ , _ ) => Action :: Delete , ( _ , true , _ , _ ) => Action :: Info , ( _ , _ , true , _ ) => Action :: List , ( _ , _ , _ , true ) => Action :: Save , _ => Action :: Pathname , } ; let directory = matches . value_of ( " " ) . map ( PathBuf :: from ) ; let path = match directory { Some ( value ) => try ! ( dir resolve ( value ) ) , None => env :: current_dir ( ) . map_err ( Error :: io ) ? , } ; let name = matches . value_of ( " " ) . map ( normalize ) . unwrap_or ( try ! ( dir basename ( path ) ) ) ; let config = config ( matches . value_of ( " " ) ) ? ; Ok ( Options { action : action , config : config , path : path , initialize : matches . is_present ( " " ) , name : name , verbose : matches . is_present ( " " ) , } ) }
Creates a new instance of Options from clap::ArgMatches.
Creates a new instance of Options from clap :: ArgMatches .
matches
clap::ArgMatches
matches
clap::ArgMatches
examples:


let matches = cli::app().get_matches_from(vec![""]);
let options = cli::Options::new(matches).unwrap().

assert_eq!(options.verbose, false);
assert_eq!(options.initialize, false);
assert_eq!(options.action, cli::Action::Pathname);
```
let matches = cli :: app () . get_matches_from ( vec! [ " " ] ) ; let options = cli :: Options :: new ( matches ) . unwrap () . assert_eq! ( options . verbose false ) ; assert_eq! ( options . initialize false ) ; assert_eq! ( options . action cli :: Action :: Pathname ) ; ` ` `