From bd10dadebe68ff0f6d1b675aef543fd9885430b6 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Fri, 17 Apr 2015 17:19:10 -0400 Subject: [PATCH] chore(docs): rebuild docs after refactor --- docs/clap/args/argbuilder/index.html | 0 docs/clap/args/argbuilder/sidebar-items.js | 1 + docs/clap/index.html | 2 +- docs/clap/macro.arg_enum!.html | 2 +- docs/clap/macro.simple_enum!.html | 2 +- docs/clap/macro.value_t!.html | 2 +- docs/clap/macro.value_t_or_exit!.html | 2 +- docs/clap/sidebar-items.js | 2 +- docs/clap/struct.App.html | 2 +- docs/clap/struct.Arg.html | 2 +- docs/clap/struct.ArgMatches.html | 4 +- docs/clap/struct.SubCommand.html | 2 +- docs/main.js | 20 ++-- docs/src/clap/app.rs.html | 122 ++++++++++----------- docs/src/clap/args/arg.rs.html | 2 +- docs/src/clap/args/argbuilder/mod.rs.html | 107 ++++++++++++++++++ docs/src/clap/args/argmatches.rs.html | 82 +++----------- docs/src/clap/args/mod.rs.html | 12 +- docs/src/clap/lib.rs.html | 2 +- 19 files changed, 211 insertions(+), 159 deletions(-) create mode 100644 docs/clap/args/argbuilder/index.html create mode 100644 docs/clap/args/argbuilder/sidebar-items.js create mode 100644 docs/src/clap/args/argbuilder/mod.rs.html diff --git a/docs/clap/args/argbuilder/index.html b/docs/clap/args/argbuilder/index.html new file mode 100644 index 00000000..e69de29b diff --git a/docs/clap/args/argbuilder/sidebar-items.js b/docs/clap/args/argbuilder/sidebar-items.js new file mode 100644 index 00000000..48333d31 --- /dev/null +++ b/docs/clap/args/argbuilder/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({}); \ No newline at end of file diff --git a/docs/clap/index.html b/docs/clap/index.html index 51eb0539..4f4b2320 100644 --- a/docs/clap/index.html +++ b/docs/clap/index.html @@ -114,7 +114,7 @@
  • Specific Value Sets: Positional or Option Arguments can optionally define a specific set of allowed values (i.e. imagine a --mode option which may only have one of two values fast or slow such as --mode fast or --mode slow)
  • Default Values: Although not specifically provided by clap you can achieve this exact functionality from Rust's Option<&str>.unwrap_or("some default") method (or Result<T,String>.unwrap_or(T) when using typed values)
  • Automatic Version from Cargo.toml: clap is fully compatible with Rust's env!() macro for automatically setting the version of your application to the version in your Cargo.toml. See examples/09_AutoVersion.rs for how to do this (Thanks to jhelwig for pointing this out)
  • -
  • Typed Values: You can use several convenience macros provided by clap to get typed values (i.e. i32, u8, etc.) from positional or option arguments so long as the type you request implements std::str::FromStr See the examples/12_TypedValues.rs. You can also use claps simple_enum! macro to create an enum with variants that automatically implements std::str::FromStr in order to use with the other clap macros. See examples/13a_EnumValuesAutomatic.rs for details.
  • +
  • Typed Values: You can use several convenience macros provided by clap to get typed values (i.e. i32, u8, etc.) from positional or option arguments so long as the type you request implements std::str::FromStr See the examples/12_TypedValues.rs. You can also use claps simple_enum! or arg_enum! macro to create an enum with variants that automatically implements std::str::FromStr. See examples/13a_EnumValuesAutomatic.rs for details.
  • clap::arg_enum! [-] [+] - [src]

    + [src]

     macro_rules! arg_enum {
     	(enum $e:ident { $($v:ident),+ } ) => {
    diff --git a/docs/clap/macro.simple_enum!.html b/docs/clap/macro.simple_enum!.html
    index 26792b7c..80c7f673 100644
    --- a/docs/clap/macro.simple_enum!.html
    +++ b/docs/clap/macro.simple_enum!.html
    @@ -43,7 +43,7 @@
         

    clap::simple_enum! [-] [+] - [src]

    + [src]
     macro_rules! simple_enum {
     	($e:ident => $($v:ident),+) => {
    diff --git a/docs/clap/macro.value_t!.html b/docs/clap/macro.value_t!.html
    index c895cea3..d8754771 100644
    --- a/docs/clap/macro.value_t!.html
    +++ b/docs/clap/macro.value_t!.html
    @@ -43,7 +43,7 @@
         

    clap::value_t! [-] [+] - [src]

    + [src]
     macro_rules! value_t {
     	($m:ident.value_of($v:expr), $t:ty) => {
    diff --git a/docs/clap/macro.value_t_or_exit!.html b/docs/clap/macro.value_t_or_exit!.html
    index b7859b0f..5cee15ff 100644
    --- a/docs/clap/macro.value_t_or_exit!.html
    +++ b/docs/clap/macro.value_t_or_exit!.html
    @@ -43,7 +43,7 @@
         

    clap::value_t_or_exit! [-] [+] - [src]

    + [src]
     macro_rules! value_t_or_exit {
     	($m:ident.value_of($v:expr), $t:ty) => {
    diff --git a/docs/clap/sidebar-items.js b/docs/clap/sidebar-items.js
    index ee9b216f..5772e44d 100644
    --- a/docs/clap/sidebar-items.js
    +++ b/docs/clap/sidebar-items.js
    @@ -1 +1 @@
    -initSidebarItems({"struct":[["App","Used to create a representation of a command line program and all possible command line arguments for parsing at runtime."],["Arg","The abstract representation of a command line argument used by the consumer of the library. Used to set all the options and relationships that define a valid argument for the program."],["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime by the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct."],["SubCommand","The abstract representation of a command line subcommand used by the consumer of the library."]],"macro":[["arg_enum!","Convenience macro to generate more complete enums with variants to be used as a type when parsing  arguments."],["simple_enum!","Convenience macro generated a simple enum with variants to be used as a type when parsing  arguments."],["value_t!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr`  This macro returns a `Result` which allows you as the developer to decide  what you'd like to do on a failed parse. There are two types of errors, parse failures  and those where the argument wasn't present (such as a non-required argument). "],["value_t_or_exit!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr`  This macro returns a `T` or `Vec` or exits with a usage string upon failure. This  removes some of the boiler plate to handle failures from value_t! above. "]]});
    \ No newline at end of file
    +initSidebarItems({"macro":[["arg_enum!","Convenience macro to generate more complete enums with variants to be used as a type when parsing  arguments."],["simple_enum!","Convenience macro generated a simple enum with variants to be used as a type when parsing  arguments."],["value_t!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr`  This macro returns a `Result` which allows you as the developer to decide  what you'd like to do on a failed parse. There are two types of errors, parse failures  and those where the argument wasn't present (such as a non-required argument). "],["value_t_or_exit!","Convenience macro getting a typed value `T` where `T` implements `std::str::FromStr`  This macro returns a `T` or `Vec` or exits with a usage string upon failure. This  removes some of the boiler plate to handle failures from value_t! above. "]],"struct":[["App","Used to create a representation of a command line program and all possible command line arguments for parsing at runtime."],["Arg","The abstract representation of a command line argument used by the consumer of the library. Used to set all the options and relationships that define a valid argument for the program."],["ArgMatches","Used to get information about the arguments that where supplied to the program at runtime by the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct."],["SubCommand","The abstract representation of a command line subcommand used by the consumer of the library."]]});
    \ No newline at end of file
    diff --git a/docs/clap/struct.App.html b/docs/clap/struct.App.html
    index 4e1d6641..728c4ef8 100644
    --- a/docs/clap/struct.App.html
    +++ b/docs/clap/struct.App.html
    @@ -43,7 +43,7 @@
         

    Struct clap::App [-] [+] - [src]

    + [src]
    pub struct App<'a, 'v, 'ab, 'u, 'ar> {
         // some fields omitted
     }

    Used to create a representation of a command line program and all possible command line diff --git a/docs/clap/struct.Arg.html b/docs/clap/struct.Arg.html index 58bf5187..90caf69f 100644 --- a/docs/clap/struct.Arg.html +++ b/docs/clap/struct.Arg.html @@ -43,7 +43,7 @@

    Struct clap::Arg [-] [+] - [src]

    + [src]
    pub struct Arg<'n, 'l, 'h, 'b, 'p, 'r> {
         // some fields omitted
     }

    The abstract representation of a command line argument used by the consumer of the library. diff --git a/docs/clap/struct.ArgMatches.html b/docs/clap/struct.ArgMatches.html index f4ca0bd4..89d5f5e9 100644 --- a/docs/clap/struct.ArgMatches.html +++ b/docs/clap/struct.ArgMatches.html @@ -43,7 +43,7 @@

    Struct clap::ArgMatches [-] [+] - [src]

    + [src]
    pub struct ArgMatches<'a> {
         // some fields omitted
     }

    Used to get information about the arguments that where supplied to the program at runtime by @@ -100,7 +100,7 @@ prefer values_of() as value_of() will only return the println!("Value for output: {}", o); }

    -

    fn values_of<'n>(&self, name: &'n str) -> Option<Vec<&str>>

    +

    fn values_of<'n>(&'a self, name: &'n str) -> Option<Vec<&'a str>>

    Gets the values of a specific option or positional argument in a vector (i.e. an argument that takes multiple values at runtime). If the option wasn't present at runtime it returns None

    diff --git a/docs/clap/struct.SubCommand.html b/docs/clap/struct.SubCommand.html index 9f9906b7..2ef9dafc 100644 --- a/docs/clap/struct.SubCommand.html +++ b/docs/clap/struct.SubCommand.html @@ -43,7 +43,7 @@

    Struct clap::SubCommand [-] [+] - [src]

    + [src]
    pub struct SubCommand<'a> {
         pub name: String,
         pub matches: ArgMatches<'a>,
    diff --git a/docs/main.js b/docs/main.js
    index ca6d9441..c3ab375a 100644
    --- a/docs/main.js
    +++ b/docs/main.js
    @@ -78,9 +78,11 @@
                 return;
             }
     
    -        if (e.which === 191 && $('#help').hasClass('hidden')) { // question mark
    -            e.preventDefault();
    -            $('#help').removeClass('hidden');
    +        if (e.which === 191) { // question mark
    +            if (e.shiftKey && $('#help').hasClass('hidden')) {
    +                e.preventDefault();
    +                $('#help').removeClass('hidden');
    +            }
             } else if (e.which === 27) { // esc
                 if (!$('#help').hasClass('hidden')) {
                     e.preventDefault();
    @@ -468,6 +470,8 @@
                         if ($active.length) {
                             document.location.href = $active.find('a').prop('href');
                         }
    +                } else {
    +                  $active.removeClass('highlighted');
                     }
                 });
             }
    @@ -713,10 +717,12 @@
                     if (crates[i] == window.currentCrate) {
                         klass += ' current';
                     }
    -                var desc = rawSearchIndex[crates[i]].items[0][3];
    -                div.append($('', {'href': '../' + crates[i] + '/index.html',
    -                                     'title': plainSummaryLine(desc),
    -                                     'class': klass}).text(crates[i]));
    +                if (rawSearchIndex[crates[i]].items[0]) {
    +                    var desc = rawSearchIndex[crates[i]].items[0][3];
    +                    div.append($('', {'href': '../' + crates[i] + '/index.html',
    +                                         'title': plainSummaryLine(desc),
    +                                         'class': klass}).text(crates[i]));
    +                }
                 }
                 sidebar.append(div);
             }
    diff --git a/docs/src/clap/app.rs.html b/docs/src/clap/app.rs.html
    index b93d573f..360ca884 100644
    --- a/docs/src/clap/app.rs.html
    +++ b/docs/src/clap/app.rs.html
    @@ -1369,10 +1369,6 @@
     1327
     1328
     1329
    -1330
    -1331
    -1332
    -1333
     
     use std::collections::BTreeMap;
     use std::collections::BTreeSet;
    @@ -1384,10 +1380,8 @@
     use std::process;
     use std::fmt::Write;
     
    -use args::{ ArgMatches, Arg, SubCommand };
    -use args::{FlagArg, FlagBuilder};
    -use args::{OptArg, OptBuilder};
    -use args::{PosArg, PosBuilder};
    +use args::{ ArgMatches, Arg, SubCommand, MatchedArg};
    +use args::{ FlagBuilder, OptBuilder, PosBuilder};
     
     /// Used to create a representation of a command line program and all possible command line
     /// arguments for parsing at runtime.
    @@ -2223,8 +2217,12 @@
                                     }
                                 }
                             }
    -                        if let Some(ref mut o) = matches.opts.get_mut(opt.name) {
    -                            o.values.push(arg.clone());
    +                        if let Some(ref mut o) = matches.args.get_mut(opt.name) {
    +                            // Options have values, so we can unwrap()
    +                            if let Some(ref mut vals) = o.values {
    +                                vals.push(arg.clone());
    +                            }
    +     
                                 // if it's multiple the occurrences are increased when originall found
                                 o.occurrences = if opt.multiple { o.occurrences + 1 } else { 1 };
                             }
    @@ -2285,10 +2283,12 @@
                         let mut done = false;
                         if p.multiple {
                             // Check if it's already existing and update if so...
    -                        if let Some(ref mut pa) = matches.positionals.get_mut(p.name) {
    +                        if let Some(ref mut pos) = matches.args.get_mut(p.name) {
                                 done = true;
    -                            pa.occurrences += 1;
    -                            pa.values.push(arg.clone());
    +                            pos.occurrences += 1;
    +                            if let Some(ref mut vals) = pos.values {
    +                                vals.push(arg.clone());
    +                            }
                             }
                         } else {
                             // Only increment the positional counter if it doesn't allow multiples
    @@ -2296,10 +2296,10 @@
                         }
                         // Was an update made, or is this the first occurrence?
                         if !done {
    -                        matches.positionals.insert(p.name, PosArg{
    +                        matches.args.insert(p.name, MatchedArg{
                                 name: p.name.to_owned(),
                                 occurrences: 1,
    -                            values: vec![arg.clone()],
    +                            values: Some(vec![arg.clone()]),
                             });
                         }
     
    @@ -2319,9 +2319,7 @@
                             // final required list
                             for n in reqs {
                                 self.matched_reqs.insert(n);
    -                            if matches.positionals.contains_key(n) {continue;}
    -                            if matches.opts.contains_key(n) {continue;}
    -                            if matches.flags.contains_key(n) {continue;}
    +                            if matches.args.contains_key(n) {continue;}
     
                                 self.required.insert(n);
                             }
    @@ -2436,7 +2434,7 @@
                         true, true);
                 }
     
    -            if matches.opts.contains_key(v.name) {
    +            if matches.args.contains_key(v.name) {
                     if !v.multiple {
                         self.report_error(format!("Argument --{} was supplied more than once, but does not support multiple values", arg), true, true);
                     }
    @@ -2455,16 +2453,18 @@
                         }
                     }
                     if arg_val.is_some() {
    -                    if let Some(ref mut o) = matches.opts.get_mut(v.name) {
    +                    if let Some(ref mut o) = matches.args.get_mut(v.name) {
                             o.occurrences += 1;
    -                        o.values.push(arg_val.clone().unwrap());
    +                        if let Some(ref mut vals) = o.values {
    +                            vals.push(arg_val.clone().unwrap());
    +                        }
                         }
                     }
                 } else {
    -                matches.opts.insert(v.name, OptArg{
    +                matches.args.insert(v.name, MatchedArg{
                         name: v.name.to_owned(),
                         occurrences: if arg_val.is_some() { 1 } else { 0 },
    -                    values: if arg_val.is_some() { vec![arg_val.clone().unwrap()]} else {vec![]} 
    +                    values: if arg_val.is_some() { Some(vec![arg_val.clone().unwrap()])} else { Some(vec![]) }
                     });
                 }
                 
    @@ -2482,9 +2482,7 @@
                     // final required list
                     for n in reqs {
                         self.matched_reqs.insert(n);
    -                    if matches.opts.contains_key(n) { continue; }
    -                    if matches.flags.contains_key(n) { continue; }
    -                    if matches.positionals.contains_key(n) { continue; }
    +                    if matches.args.contains_key(n) { continue; }
     
                         self.required.insert(n);
                     }
    @@ -2503,20 +2501,21 @@
                 }
                 
                 // Make sure this isn't one being added multiple times if it doesn't suppor it
    -            if matches.flags.contains_key(v.name) && !v.multiple {
    +            if matches.args.contains_key(v.name) && !v.multiple {
                     self.report_error(format!("Argument --{} was supplied more than once, but does not support multiple values", arg), true, true);
                 }
     
                 let mut 
                 done = false;
    -            if let Some(ref mut f) = matches.flags.get_mut(v.name) {
    +            if let Some(ref mut f) = matches.args.get_mut(v.name) {
                     done = true;
                     f.occurrences = if v.multiple { f.occurrences + 1 } else { 1 };
                 }
                 if !done { 
    -                matches.flags.insert(v.name, FlagArg{
    +                matches.args.insert(v.name, MatchedArg{
                         name: v.name.to_owned(),
    -                    occurrences: 1
    +                    occurrences: 1,
    +                    values: None
                     });
                 }
     
    @@ -2536,9 +2535,7 @@
                 if let Some(ref reqs) = v.requires {
                     for n in reqs {
                         self.matched_reqs.insert(n);
    -                    if matches.flags.contains_key(n) { continue; }
    -                    if matches.opts.contains_key(n) { continue; }
    -                    if matches.positionals.contains_key(n) { continue; }
    +                    if matches.args.contains_key(n) { continue; }
     
                         self.required.insert(n);
                     }
    @@ -2582,16 +2579,16 @@
                         true, true);
                 }
     
    -            if matches.opts.contains_key(v.name) {
    +            if matches.args.contains_key(v.name) {
                     if !v.multiple {
                         self.report_error(format!("Argument -{} was supplied more than once, but does not support multiple values", arg), true, true);
                     }
                 } else {
    -                matches.opts.insert(v.name, OptArg{
    +                matches.args.insert(v.name, MatchedArg{
                         name: v.name.to_owned(),
                         // occurrences will be incremented on getting a value
                         occurrences: 0,
    -                    values: vec![]
    +                    values: Some(vec![]) 
                     });
                 }
                 if let Some(ref bl) = v.blacklist {
    @@ -2608,9 +2605,7 @@
                     // final required list
                     for n in reqs {
                         self.matched_reqs.insert(n);
    -                    if matches.opts.contains_key(n) { continue; }
    -                    if matches.flags.contains_key(n) { continue; }
    -                    if matches.positionals.contains_key(n) { continue; }
    +                    if matches.args.contains_key(n) { continue; }
     
                         self.required.insert(n);
                     }
    @@ -2633,19 +2628,20 @@
                 }
     
                 // Make sure this isn't one being added multiple times if it doesn't suppor it
    -            if matches.flags.contains_key(v.name) && !v.multiple {
    +            if matches.args.contains_key(v.name) && !v.multiple {
                     self.report_error(format!("Argument -{} was supplied more than once, but does not support multiple values", arg), true, true);
                 }
     
                 let mut done = false;
    -            if let Some(ref mut f) = matches.flags.get_mut(v.name) {
    +            if let Some(ref mut f) = matches.args.get_mut(v.name) {
                     done = true;
                     f.occurrences = if v.multiple { f.occurrences + 1 } else { 1 };
                 } 
                 if !done {
    -                matches.flags.insert(v.name, FlagArg{
    +                matches.args.insert(v.name, MatchedArg{
                         name: v.name.to_owned(),
    -                    occurrences: 1
    +                    occurrences: 1,
    +                    values: None
                     });
                 }
     
    @@ -2665,9 +2661,7 @@
                 if let Some(ref reqs) = v.requires {
                     for n in reqs {
                         self.matched_reqs.insert(n);
    -                    if matches.flags.contains_key(n) { continue; }
    -                    if matches.opts.contains_key(n) { continue; }
    -                    if matches.positionals.contains_key(n) { continue; }
    +                    if matches.args.contains_key(n) { continue; }
     
                         self.required.insert(n);
                     }
    @@ -2679,30 +2673,28 @@
     
         fn validate_blacklist(&self, matches: &ArgMatches<'ar>) {
             for name in self.blacklist.iter() {
    -            if matches.flags.contains_key(name) {
    +            if matches.args.contains_key(name) {
                     self.report_error(format!("The argument {} cannot be used with one or more of the other specified arguments",
    -                    if let Some(s) = self.flags.get(name).unwrap().short {
    -                        format!("-{}", s)
    -                    } else if let Some(l) = self.flags.get(name).unwrap().long {
    -                        format!("--{}", l)
    +                    if let Some(ref flag) = self.flags.get(name) {
    +                        if let Some(short) = flag.short {
    +                            format!("-{}", short)
    +                        } else if let Some(long) = flag.long {
    +                            format!("--{}", long)
    +                        } else {
    +                            format!("\"{}\"", flag.name)
    +                        }
    +                    } else if let Some(ref opt) = self.opts.get(name) {
    +                        if let Some(short) = opt.short {
    +                            format!("-{}", short)
    +                        } else if let Some(long) = opt.long {
    +                            format!("--{}", long)
    +                        } else {
    +                            format!("\"{}\"", opt.name)
    +                        }
                         } else {
                             format!("\"{}\"", name)
                         }), true, true);
                 }
    -            if matches.opts.contains_key(name) {
    -                self.report_error(format!("The argument {} cannot be used with one or more of the other specified arguments",
    -                    if let Some(s) = self.opts.get(name).unwrap().long {
    -                        format!("--{}", s)
    -                    } else if let Some(l) = self.opts.get(name).unwrap().short {
    -                        format!("-{}", l)
    -                    } else {
    -                        format!("\"{}\"", name)
    -                    }), true, true);
    -            }
    -            if matches.positionals.contains_key(name) {
    -                self.report_error(format!("The argument \"{}\" cannot be used with one or more of the other specified arguments",name),
    -                    false, true);
    -            }
             }
         }
     
    diff --git a/docs/src/clap/args/arg.rs.html b/docs/src/clap/args/arg.rs.html
    index 688aad68..48753338 100644
    --- a/docs/src/clap/args/arg.rs.html
    +++ b/docs/src/clap/args/arg.rs.html
    @@ -684,7 +684,7 @@
         /// Arg::new("conifg")
         /// # .short("c")
         /// # ).get_matches();
    -    #[deprecated(since  = "0.5.15",
    +    #[deprecated(since  = "0.6.0",
                      reason = "use Arg::with_name() instead")]
         pub fn new(n: &'n str) -> Arg<'n, 'l, 'h, 'b, 'p, 'r> {
             Arg {
    diff --git a/docs/src/clap/args/argbuilder/mod.rs.html b/docs/src/clap/args/argbuilder/mod.rs.html
    new file mode 100644
    index 00000000..41bda93c
    --- /dev/null
    +++ b/docs/src/clap/args/argbuilder/mod.rs.html
    @@ -0,0 +1,107 @@
    +
    +
    +
    +    
    +    
    +    
    +    
    +    
    +
    +    mod.rs.html -- source
    +
    +    
    +
    +    
    +    
    +
    +
    +    
    +
    +    
    +
    +    
    +
    +    
    +
    +    
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +
    +pub use self::flag::FlagBuilder;
    +pub use self::option::OptBuilder;
    +pub use self::positional::PosBuilder;
    +
    +mod flag;
    +mod positional;
    +mod option;
    +
    +
    + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/src/clap/args/argmatches.rs.html b/docs/src/clap/args/argmatches.rs.html index 5e8e86bb..6a2001a6 100644 --- a/docs/src/clap/args/argmatches.rs.html +++ b/docs/src/clap/args/argmatches.rs.html @@ -305,38 +305,11 @@ 263 264 265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290
     use std::collections::HashMap;
     
     use args::SubCommand;
    -use args::flagarg::FlagArg;
    -use args::optarg::OptArg;
    -use args::posarg::PosArg;
    +use args::MatchedArg;
     
     /// Used to get information about the arguments that where supplied to the program at runtime by
     /// the user. To get a new instance of this struct you use `.get_matches()` of the `App` struct.
    @@ -389,11 +362,7 @@
     /// }
     pub struct ArgMatches<'a> {
         #[doc(hidden)]
    -    pub flags: HashMap<&'a str, FlagArg>,
    -    #[doc(hidden)]
    -    pub opts: HashMap<&'a str, OptArg>,
    -    #[doc(hidden)]
    -    pub positionals: HashMap<&'a str, PosArg>,
    +    pub args: HashMap<&'a str, MatchedArg>,
         #[doc(hidden)]
         pub subcommand: Option<Box<SubCommand<'a>>>,
         #[doc(hidden)]
    @@ -413,10 +382,7 @@
         #[doc(hidden)]
         pub fn new() -> ArgMatches<'a> {
             ArgMatches {
    -            // matches_of: name,
    -            flags: HashMap::new(),
    -            opts: HashMap::new(),
    -            positionals: HashMap::new(),
    +            args: HashMap::new(),
                 subcommand: None,
                 usage: None
             }
    @@ -439,14 +405,11 @@
         /// }
         /// ```
         pub fn value_of<'n>(&self, name: &'n str) -> Option<&str> {
    -        if let Some(ref opt) = self.opts.get(name) {
    -            if let Some(ref s) = opt.values.iter().nth(0) {
    -                return Some(&s[..]);
    -            }
    -        }
    -        if let Some(ref pos) = self.positionals.get(name) {
    -            if let Some(ref s) = pos.values.iter().nth(0) {
    -                return Some(&s[..]);
    +        if let Some(ref arg) = self.args.get(name) {
    +            if let Some(ref vals) = arg.values {
    +                if let Some(ref val) = vals.iter().nth(0) {
    +                    return Some(&val[..]);
    +                }
                 }
             }
             None
    @@ -470,16 +433,11 @@
         ///        }
         /// }
         /// ```
    -    pub fn values_of<'n>(&self, name: &'n str) -> Option<Vec<&str>> {
    -        if let Some(ref opt) = self.opts.get(name) {
    -            if opt.values.is_empty() { return None; } 
    -
    -            return Some(opt.values.iter().map(|s| &s[..]).collect::<Vec<_>>());
    -        }
    -        if let Some(ref pos) = self.positionals.get(name) {
    -            if pos.values.is_empty() { return None; } 
    -
    -            return Some(pos.values.iter().map(|s| &s[..]).collect::<Vec<_>>());
    +    pub fn values_of<'n>(&'a self, name: &'n str) -> Option<Vec<&'a str>> {
    +        if let Some(ref arg) = self.args.get(name) {
    +            if let Some(ref vals) = arg.values {
    +                return Some(vals.iter().map(|s| &s[..]).collect::<Vec<_>>());
    +            }
             }
             None
         }
    @@ -500,9 +458,7 @@
             if let Some(ref sc) = self.subcommand {
                 if sc.name == name { return true; } 
             }
    -        if self.flags.contains_key(name) {return true;}
    -        if self.opts.contains_key(name) {return true;}
    -        if self.positionals.contains_key(name) {return true;}
    +        if self.args.contains_key(name) {return true;}
             false
         }
     
    @@ -523,14 +479,8 @@
         /// }
         /// ```
         pub fn occurrences_of<'n>(&self, name: &'n str) -> u8 {
    -        if let Some(ref f) = self.flags.get(name) {
    -            return f.occurrences;
    -        }
    -        if let Some(ref o) = self.opts.get(name) {
    -            return o.occurrences;
    -        }
    -        if let Some(ref p) = self.positionals.get(name) {
    -            return p.occurrences;
    +        if let Some(ref arg) = self.args.get(name) {
    +            return arg.occurrences;
             }
             0
         }
    diff --git a/docs/src/clap/args/mod.rs.html b/docs/src/clap/args/mod.rs.html
    index e241f079..8697757b 100644
    --- a/docs/src/clap/args/mod.rs.html
    +++ b/docs/src/clap/args/mod.rs.html
    @@ -51,22 +51,18 @@
      9
     10
     11
    -12
    -13
     
     pub use self::arg::Arg;
     pub use self::argmatches::ArgMatches;
     pub use self::subcommand::SubCommand;
    -pub use self::flagarg::{FlagArg, FlagBuilder};
    -pub use self::optarg::{OptArg, OptBuilder};
    -pub use self::posarg::{PosArg, PosBuilder};
    +pub use self::argbuilder::{FlagBuilder, OptBuilder, PosBuilder};
    +pub use self::matchedarg::MatchedArg;
     
     mod arg;
     mod argmatches;
     mod subcommand;
    -mod flagarg;
    -mod optarg;
    -mod posarg;
    +mod argbuilder;
    +mod matchedarg;
     
    diff --git a/docs/src/clap/lib.rs.html b/docs/src/clap/lib.rs.html index 7ffecfe8..b3c8609d 100644 --- a/docs/src/clap/lib.rs.html +++ b/docs/src/clap/lib.rs.html @@ -998,7 +998,7 @@ //! * **Specific Value Sets**: Positional or Option Arguments can optionally define a specific set of allowed values (i.e. imagine a `--mode` option which may *only* have one of two values `fast` or `slow` such as `--mode fast` or `--mode slow`) //! * **Default Values**: Although not specifically provided by `clap` you can achieve this exact functionality from Rust's `Option<&str>.unwrap_or("some default")` method (or `Result<T,String>.unwrap_or(T)` when using typed values) //! * **Automatic Version from Cargo.toml**: `clap` is fully compatible with Rust's `env!()` macro for automatically setting the version of your application to the version in your Cargo.toml. See `examples/09_AutoVersion.rs` for how to do this (Thanks to [jhelwig](https://github.com/jhelwig) for pointing this out) -//! * **Typed Values**: You can use several convenience macros provided by `clap` to get typed values (i.e. `i32`, `u8`, etc.) from positional or option arguments so long as the type you request implements `std::str::FromStr` See the `examples/12_TypedValues.rs`. You can also use `clap`s `simple_enum!` macro to create an enum with variants that automatically implements `std::str::FromStr` in order to use with the other `clap` macros. See `examples/13a_EnumValuesAutomatic.rs` for details. +//! * **Typed Values**: You can use several convenience macros provided by `clap` to get typed values (i.e. `i32`, `u8`, etc.) from positional or option arguments so long as the type you request implements `std::str::FromStr` See the `examples/12_TypedValues.rs`. You can also use `clap`s `simple_enum!` or `arg_enum!` macro to create an enum with variants that automatically implements `std::str::FromStr`. See `examples/13a_EnumValuesAutomatic.rs` for details. //! //! ## Quick Example //!