From 9f8fced0abc2d6fc07714246cd9ebcb3bb80d6b9 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Fri, 10 Apr 2015 11:55:20 -0400 Subject: [PATCH] chore(docs): rebuild documentation --- docs/clap/index.html | 2 +- docs/clap/struct.App.html | 2 +- docs/clap/struct.Arg.html | 2 +- docs/clap/struct.ArgMatches.html | 8 ++-- docs/clap/struct.SubCommand.html | 2 +- docs/search-index.js | 2 +- docs/src/clap/app.rs.html | 64 +++++++-------------------- docs/src/clap/args/argmatches.rs.html | 14 +++--- docs/src/clap/lib.rs.html | 4 ++ 9 files changed, 39 insertions(+), 61 deletions(-) diff --git a/docs/clap/index.html b/docs/clap/index.html index e8df3eb2..01666b90 100644 --- a/docs/clap/index.html +++ b/docs/clap/index.html @@ -43,7 +43,7 @@

Crate clap[stability] [-] [+] - [src]

+ [src]

clap

diff --git a/docs/clap/struct.App.html b/docs/clap/struct.App.html index 0d923aab..42fbd875 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 the program and all possible command line arguments diff --git a/docs/clap/struct.Arg.html b/docs/clap/struct.Arg.html index 1150e90a..c5e81399 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> {
     pub name: &'n str,
     pub short: Option<char>,
diff --git a/docs/clap/struct.ArgMatches.html b/docs/clap/struct.ArgMatches.html
index cc6d95eb..19ff12b7 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> {
     pub flags: HashMap<&'a str, FlagArg>,
     pub opts: HashMap<&'a str, OptArg>,
@@ -189,12 +189,12 @@ allow multiple occurrences, it will return 1 no matter how many tim
     _                         => {}, // Either no subcommand or one not tested for...
 }
 
-

fn usage(&self) -> Option<&str>

-

Returns a slice of the default usage for the top level parent App only

+

fn usage(&self) -> &str

+

Returns a slice of the usage

Example

-println!("{}",app_matches.usage().unwrap());
+println!("{}",app_matches.usage());
 
diff --git a/docs/clap/struct.SubCommand.html b/docs/clap/struct.SubCommand.html index 38c60190..aa5c1920 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/search-index.js b/docs/search-index.js
index 98c9294b..24e68c67 100644
--- a/docs/search-index.js
+++ b/docs/search-index.js
@@ -1,3 +1,3 @@
 var searchIndex = {};
-searchIndex['clap'] = {"items":[[0,"","clap","# clap",null,null],[3,"Arg","","The abstract representation of a command line argument used by the consumer of the library.",null,null],[12,"name","","The unique name of the argument, required",0,null],[12,"short","","The short version (i.e. single character) of the argument, no preceding `-`\n**NOTE:** `short` is mutually exclusive with `index`",0,null],[12,"long","","The long version of the flag (i.e. word) without the preceding `--`\n**NOTE:** `long` is mutually exclusive with `index`",0,null],[12,"help","","The string of text that will displayed to the user when the application's\n`help` text is displayed",0,null],[12,"required","","If this is a required by default when using the command line program\ni.e. a configuration file that's required for the program to function\n**NOTE:** required by default means, it is required *until* mutually\nexclusive arguments are evaluated.",0,null],[12,"takes_value","","Determines if this argument is an option, vice a flag or positional and\nis mutually exclusive with `index` and `multiple`",0,null],[12,"index","","The index of the argument. `index` is mutually exclusive with `takes_value`\nand `multiple`",0,null],[12,"multiple","","Determines if multiple instances of the same flag are allowed. `multiple`\nis mutually exclusive with `index` and `takes_value`.\nI.e. `-v -v -v` or `-vvv`",0,null],[12,"blacklist","","A list of names for other arguments that *may not* be used with this flag",0,null],[12,"possible_vals","","A list of possible values for an option or positional argument",0,null],[12,"requires","","A list of names of other arguments that are *required* to be used when\nthis flag is used",0,null],[3,"SubCommand","","The abstract representation of a command line subcommand used by the consumer of the library.",null,null],[12,"name","","",1,null],[12,"matches","","",1,null],[3,"ArgMatches","","Used to get information about the arguments that\nwhere supplied to the program at runtime.",null,null],[12,"flags","","",2,null],[12,"opts","","",2,null],[12,"positionals","","",2,null],[12,"subcommand","","",2,null],[12,"usage","","",2,null],[3,"App","","Used to create a representation of the program and all possible command line arguments\nfor parsing at runtime.",null,null],[11,"new","","Creates a new instance of an application requiring a name (such as the binary). Will be displayed\nto the user when they print version or help and usage information.",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"author","","Sets a string of author(s)",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"about","","Sets a string briefly describing what the program does",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"version","","Sets a string of the version number",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"usage","","Sets a custom usage string to over-ride the one auto-generated by `clap`",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"arg","","Adds an argument to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"arg"}],"output":{"name":"app"}}],[11,"args","","Adds multiple arguments to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"vec"}],"output":{"name":"app"}}],[11,"subcommand","","Adds a subcommand to the list of valid possibilties. Subcommands\nare effectively sub apps, because they can contain their own arguments\nand subcommands. They also function just like apps, in that they get their\nown auto generated help and version switches.",3,{"inputs":[{"name":"app"},{"name":"app"}],"output":{"name":"app"}}],[11,"subcommands","","Adds multiple subcommands to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"vec"}],"output":{"name":"app"}}],[11,"get_matches","","",3,{"inputs":[{"name":"app"}],"output":{"name":"argmatches"}}],[11,"new","","Creates a new instace of `Arg` using a unique string name.\nThe name will be used by the library consumer to get information about\nwhether or not the argument was used at runtime. ",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"short","","Sets the short version of the argument without the preceding `-`.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"long","","Sets the long version of the argument without the preceding `--`.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"help","","Sets the help text of the argument that will be displayed to the user\nwhen they print the usage/help information. ",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"required","","Sets whether or not the argument is required by default. Required by\ndefault means it is required, when no other mutually exlusive rules have\nbeen evaluated. Mutually exclusive rules take precedence over being required\nby default.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"mutually_excludes","","Sets a mutually exclusive argument by name. I.e. when using this argument,\nthe following argument can't be present.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"mutually_excludes_all","","Sets a mutually exclusive arguments by names. I.e. when using this argument,\nthe following argument can't be present.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"requires","","Sets an argument by name that is required when this one is presnet I.e. when\nusing this argument, the following argument *must* be present.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"requires_all","","Sets arguments by names that are required when this one is presnet I.e. when\nusing this argument, the following arguments *must* be present.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"takes_value","","Specifies that the argument takes an additional value at run time.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"index","","Specifies the index of a positional argument starting at 1.",0,{"inputs":[{"name":"arg"},{"name":"u8"}],"output":{"name":"arg"}}],[11,"multiple","","Specifies if the flag may appear more than once such as for multiple debugging\nlevels (as an example). `-ddd` for three levels of debugging, or `-d -d -d`. \nWhen this is set to `true` you recieve the number of occurances the user supplied\nof a particular flag at runtime.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"possible_values","","Specifies a list of possible values for this argument. At runtime, clap verifies that only\none of the specified values was used, or fails with a usage string.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"new","","Creates a new instance of `ArgMatches`. This ins't called directly, but\nthrough the `.get_matches()` method of `App`",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"argmatches"}}],[11,"value_of","","Gets the value of a specific option or positional argument (i.e. an argument that takes\nan additional value at runtime). If the option wasn't present at runtime\nit returns `None`. ",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"values_of","","Gets the values of a specific option or positional argument in a vector (i.e. an argument\nthat takes an additional value at runtime). If the option wasn't present at runtime it\nreturns `None`",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"is_present","","Checks if a flag was argument was supplied at runtime. **DOES NOT** work for\noption or positional arguments (use `.value_of()` instead)",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"bool"}}],[11,"occurrences_of","","Checks the number of occurrences of an option, flag, or positional argument at runtime.\nIf an option or flag isn't present it will return `0`, if the option or flag doesn't \nallow multiple occurrences, it will return `1` no matter how many times it occurred \n(unless it wasn't prsent) at all.",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"u8"}}],[11,"subcommand_matches","","If a subcommand was found, returns the ArgMatches struct associated with it's matches",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"subcommand_name","","If a subcommand was found, returns the name associated with it",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"option"}}],[11,"subcommand","","If a subcommand was found, returns the name and matches associated with it",2,null],[11,"usage","","Returns a slice of the default usage for the *top level parent App only*",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"option"}}],[11,"new","","Creates a new instance of a subcommand requiring a name. Will be displayed\nto the user when they print version or help and usage information.",1,{"inputs":[{"name":"subcommand"},{"name":"str"}],"output":{"name":"app"}}]],"paths":[[3,"Arg"],[3,"SubCommand"],[3,"ArgMatches"],[3,"App"]]};
+searchIndex['clap'] = {"items":[[0,"","clap","# clap",null,null],[3,"Arg","","The abstract representation of a command line argument used by the consumer of the library.",null,null],[12,"name","","The unique name of the argument, required",0,null],[12,"short","","The short version (i.e. single character) of the argument, no preceding `-`\n**NOTE:** `short` is mutually exclusive with `index`",0,null],[12,"long","","The long version of the flag (i.e. word) without the preceding `--`\n**NOTE:** `long` is mutually exclusive with `index`",0,null],[12,"help","","The string of text that will displayed to the user when the application's\n`help` text is displayed",0,null],[12,"required","","If this is a required by default when using the command line program\ni.e. a configuration file that's required for the program to function\n**NOTE:** required by default means, it is required *until* mutually\nexclusive arguments are evaluated.",0,null],[12,"takes_value","","Determines if this argument is an option, vice a flag or positional and\nis mutually exclusive with `index` and `multiple`",0,null],[12,"index","","The index of the argument. `index` is mutually exclusive with `takes_value`\nand `multiple`",0,null],[12,"multiple","","Determines if multiple instances of the same flag are allowed. `multiple`\nis mutually exclusive with `index` and `takes_value`.\nI.e. `-v -v -v` or `-vvv`",0,null],[12,"blacklist","","A list of names for other arguments that *may not* be used with this flag",0,null],[12,"possible_vals","","A list of possible values for an option or positional argument",0,null],[12,"requires","","A list of names of other arguments that are *required* to be used when\nthis flag is used",0,null],[3,"SubCommand","","The abstract representation of a command line subcommand used by the consumer of the library.",null,null],[12,"name","","",1,null],[12,"matches","","",1,null],[3,"ArgMatches","","Used to get information about the arguments that\nwhere supplied to the program at runtime.",null,null],[12,"flags","","",2,null],[12,"opts","","",2,null],[12,"positionals","","",2,null],[12,"subcommand","","",2,null],[12,"usage","","",2,null],[3,"App","","Used to create a representation of the program and all possible command line arguments\nfor parsing at runtime.",null,null],[11,"new","","Creates a new instance of an application requiring a name (such as the binary). Will be displayed\nto the user when they print version or help and usage information.",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"author","","Sets a string of author(s)",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"about","","Sets a string briefly describing what the program does",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"version","","Sets a string of the version number",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"usage","","Sets a custom usage string to over-ride the one auto-generated by `clap`",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"arg","","Adds an argument to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"arg"}],"output":{"name":"app"}}],[11,"args","","Adds multiple arguments to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"vec"}],"output":{"name":"app"}}],[11,"subcommand","","Adds a subcommand to the list of valid possibilties. Subcommands\nare effectively sub apps, because they can contain their own arguments\nand subcommands. They also function just like apps, in that they get their\nown auto generated help and version switches.",3,{"inputs":[{"name":"app"},{"name":"app"}],"output":{"name":"app"}}],[11,"subcommands","","Adds multiple subcommands to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"vec"}],"output":{"name":"app"}}],[11,"get_matches","","",3,{"inputs":[{"name":"app"}],"output":{"name":"argmatches"}}],[11,"new","","Creates a new instace of `Arg` using a unique string name.\nThe name will be used by the library consumer to get information about\nwhether or not the argument was used at runtime. ",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"short","","Sets the short version of the argument without the preceding `-`.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"long","","Sets the long version of the argument without the preceding `--`.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"help","","Sets the help text of the argument that will be displayed to the user\nwhen they print the usage/help information. ",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"required","","Sets whether or not the argument is required by default. Required by\ndefault means it is required, when no other mutually exlusive rules have\nbeen evaluated. Mutually exclusive rules take precedence over being required\nby default.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"mutually_excludes","","Sets a mutually exclusive argument by name. I.e. when using this argument,\nthe following argument can't be present.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"mutually_excludes_all","","Sets a mutually exclusive arguments by names. I.e. when using this argument,\nthe following argument can't be present.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"requires","","Sets an argument by name that is required when this one is presnet I.e. when\nusing this argument, the following argument *must* be present.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"requires_all","","Sets arguments by names that are required when this one is presnet I.e. when\nusing this argument, the following arguments *must* be present.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"takes_value","","Specifies that the argument takes an additional value at run time.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"index","","Specifies the index of a positional argument starting at 1.",0,{"inputs":[{"name":"arg"},{"name":"u8"}],"output":{"name":"arg"}}],[11,"multiple","","Specifies if the flag may appear more than once such as for multiple debugging\nlevels (as an example). `-ddd` for three levels of debugging, or `-d -d -d`. \nWhen this is set to `true` you recieve the number of occurances the user supplied\nof a particular flag at runtime.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"possible_values","","Specifies a list of possible values for this argument. At runtime, clap verifies that only\none of the specified values was used, or fails with a usage string.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"new","","Creates a new instance of `ArgMatches`. This ins't called directly, but\nthrough the `.get_matches()` method of `App`",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"argmatches"}}],[11,"value_of","","Gets the value of a specific option or positional argument (i.e. an argument that takes\nan additional value at runtime). If the option wasn't present at runtime\nit returns `None`. ",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"values_of","","Gets the values of a specific option or positional argument in a vector (i.e. an argument\nthat takes an additional value at runtime). If the option wasn't present at runtime it\nreturns `None`",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"is_present","","Checks if a flag was argument was supplied at runtime. **DOES NOT** work for\noption or positional arguments (use `.value_of()` instead)",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"bool"}}],[11,"occurrences_of","","Checks the number of occurrences of an option, flag, or positional argument at runtime.\nIf an option or flag isn't present it will return `0`, if the option or flag doesn't \nallow multiple occurrences, it will return `1` no matter how many times it occurred \n(unless it wasn't prsent) at all.",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"u8"}}],[11,"subcommand_matches","","If a subcommand was found, returns the ArgMatches struct associated with it's matches",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"subcommand_name","","If a subcommand was found, returns the name associated with it",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"option"}}],[11,"subcommand","","If a subcommand was found, returns the name and matches associated with it",2,null],[11,"usage","","Returns a slice of the usage",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"str"}}],[11,"new","","Creates a new instance of a subcommand requiring a name. Will be displayed\nto the user when they print version or help and usage information.",1,{"inputs":[{"name":"subcommand"},{"name":"str"}],"output":{"name":"app"}}]],"paths":[[3,"Arg"],[3,"SubCommand"],[3,"ArgMatches"],[3,"App"]]};
 initSearch(searchIndex);
diff --git a/docs/src/clap/app.rs.html b/docs/src/clap/app.rs.html
index 030d5ebc..31807059 100644
--- a/docs/src/clap/app.rs.html
+++ b/docs/src/clap/app.rs.html
@@ -1285,21 +1285,6 @@
 1243
 1244
 1245
-1246
-1247
-1248
-1249
-1250
-1251
-1252
-1253
-1254
-1255
-1256
-1257
-1258
-1259
-1260
 
 use std::collections::BTreeMap;
 use std::collections::BTreeSet;
@@ -1730,7 +1715,7 @@
                 }
             }
 
-            let req_pos = self.positionals_idx.values().filter_map(|ref x| if x.required || matched_pos_reqs.contains(x.name) { 
+            let mut req_pos = self.positionals_idx.values().filter_map(|ref x| if x.required || matched_pos_reqs.contains(x.name) { 
                 num_req_pos += 1;
                 if x.multiple {
                     Some(format!("<{}>...", x.name))
@@ -1740,19 +1725,21 @@
             } else {
                 None
             } )
-                                                       .fold(String::new(), |acc, ref name| acc + &format!("{} ", name)[..]);
+                                                       .fold(String::with_capacity(50), |acc, ref name| acc + &format!("{} ", name)[..]);
+            req_pos.shrink_to_fit();
             let mut num_req_opts = 0;
-            let req_opts = self.opts.values().filter_map(|x| if x.required  || self.matched_reqs.contains(x.name) {
+            let mut req_opts = self.opts.values().filter_map(|x| if x.required  || self.matched_reqs.contains(x.name) {
                 num_req_opts += 1;
                 Some(x)
             }else {
                 None
             })
-                                             .fold(String::new(), |acc, ref o| acc + &format!("-{}{} ",if let Some(l) = o.long {
+                                             .fold(String::with_capacity(50), |acc, ref o| acc + &format!("-{}{} ",if let Some(l) = o.long {
                                                                                                      format!("-{}=", l)
                                                                                                    } else {
                                                                                                        format!("{} ",o.short.unwrap())
                                                                                                    },o.name));
+            req_opts.shrink_to_fit();
 
             // usage.push_str(tab);
             usage.push_str(&self.bin_name.clone().unwrap_or(self.name.clone())[..]);
@@ -1763,22 +1750,22 @@
             if opts {
                 write!(&mut usage," {}",
                     if num_req_opts != self.opts.len() && !req_opts.is_empty() { 
-                        format!(" [OPTIONS] {}", &req_opts[..])
+                        format!("[OPTIONS] {}", &req_opts[..])
                     } else if req_opts.is_empty() { 
-                        " [OPTIONS]".to_owned()
+                        "[OPTIONS]".to_owned()
                     } else {
                         req_opts
-                    });
+                    }).unwrap_or_else(|e| self.report_error(format!("internal error: {}", e),false,true));
             }
             if pos {
                 write!(&mut usage, " {}",
                     if num_req_pos != self.positionals_idx.len() && !req_pos.is_empty() { 
-                        format!(" [POSITIONAL] {}", &req_pos[..])
+                        format!("[POSITIONAL] {}", &req_pos[..])
                     } else if req_pos.is_empty() { 
-                        " [POSITIONAL]".to_owned()
+                        "[POSITIONAL]".to_owned()
                     } else {
                         req_pos
-                    } );
+                    } ).unwrap_or_else(|e| self.report_error(format!("internal error: {}", e),false,true));
             }
             if subcmds {
                 usage.push_str(" [SUBCOMMANDS]");
@@ -1892,16 +1879,7 @@
                             // 7 is '--=' (3) + tab (4)
                             self.get_spaces((longest_opt + 6) - (v.name.len() + mult))
                         },
-                        if let Some(h) = v.help {
-                            format!("{}{}", h,
-                                if let Some(ref pv) = v.possible_vals {
-                                    format!(" [values:{}]", pv.iter().fold(String::new(), |acc, name| acc + &format!(" {}",name)[..] ))
-                                }else{
-                                    "".to_owned()
-                                })
-                        } else {
-                            tab.to_owned()
-                        } );
+                        get_help!(v) );
             }
         }
         if pos {
@@ -1912,15 +1890,7 @@
                 println!("{}{}{}{}",tab,
                     if v.multiple {format!("{}...",v.name)} else {v.name.to_owned()},
                     self.get_spaces((longest_pos + 4) - (v.name.len() + mult)),
-                    if let Some(h) = v.help {
-                        format!("{}{}",
-                            h,
-                            if let Some(ref pv) = v.possible_vals {
-                                format!(" [values:{}]", pv.iter().fold(String::new(), |acc, name| acc + &format!(" {}",name)[..] ))
-                            }else{"".to_owned()})
-                    } else {
-                        tab.to_owned()
-                    } );
+                    get_help!(v));
             }
         }
         if subcmds {
@@ -2009,7 +1979,6 @@
                 }
             }
         }
-        matches.usage = Some(self.create_usage());
         self.get_matches_from(&mut matches, &mut it );
 
         matches
@@ -2114,7 +2083,7 @@
 
                 if self.positionals_idx.is_empty() {
                     self.report_error(
-                        format!("Found positional argument {}, but {} doesn't accept any", arg, self.name),
+                        format!("Argument \"{}\" isn't a valid option for {}", arg, self.bin_name.clone().unwrap_or(self.name.clone())),
                         true, true);
                 }
                 // If we find that an argument requires a positiona, we need to update all the
@@ -2182,7 +2151,7 @@
                         }
                     }
                 } else {
-                    self.report_error(format!("Positional argument \"{}\" was found, but {} wasn't expecting any", arg, self.name), true, true);
+                    self.report_error(format!("Argument \"{}\" isn't a valid argument for {}", arg, self.bin_name.clone().unwrap_or(self.name.clone())), true, true);
                 }
             }
         }
@@ -2202,6 +2171,7 @@
                     true, true);
         }
 
+        matches.usage = Some(self.create_usage());
 
         if let Some(sc_name) = subcmd_name {
             if let Some(ref mut sc) = self.subcommands.get_mut(&sc_name) {
diff --git a/docs/src/clap/args/argmatches.rs.html b/docs/src/clap/args/argmatches.rs.html
index 08a57111..91af7c8d 100644
--- a/docs/src/clap/args/argmatches.rs.html
+++ b/docs/src/clap/args/argmatches.rs.html
@@ -325,6 +325,8 @@
 283
 284
 285
+286
+287
 
 use std::collections::HashMap;
 
@@ -594,7 +596,7 @@
         ("", None)
     }
 
-    /// Returns a slice of the default usage for the *top level parent App only*
+    /// Returns a slice of the usage
     ///
     ///
     /// # Example
@@ -602,13 +604,15 @@
     /// ```no_run
     /// # use clap::{App, Arg, SubCommand};
     /// # let app_matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();
-    /// println!("{}",app_matches.usage().unwrap());
+    /// println!("{}",app_matches.usage());
     /// ```
-    pub fn usage(&self) -> Option<&str> {
+    pub fn usage(&self) -> &str {
         if let Some( ref u ) = self.usage {
-            return Some(&u[..]);
+            return &u[..];
         }
-        None
+
+        // Should be un-reachable
+        ""
     }
 }
 
diff --git a/docs/src/clap/lib.rs.html b/docs/src/clap/lib.rs.html index 9822700f..b048579b 100644 --- a/docs/src/clap/lib.rs.html +++ b/docs/src/clap/lib.rs.html @@ -379,6 +379,8 @@ 337 338 339 +340 +341
 #![crate_type= "lib"]
 
@@ -613,6 +615,8 @@
 pub use args::{Arg, SubCommand, ArgMatches};
 pub use app::App;
 
+#[macro_use]
+mod macros;
 mod app;
 mod args;