diff --git a/src/app.rs b/src/app.rs index 4089f83fcdb..2a8fd997dbb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -36,7 +36,7 @@ use args::{PosArg, PosBuilder}; /// /// // Your pogram logic starts here... /// ``` -pub struct App<'a, 'v, 'ab, 'u> { +pub struct App<'a, 'v, 'ab, 'u, 'ar> { // The name displayed to the user when showing version and help/usage information name: String, // A string of author(s) if desired. Displayed when showing help/usage information @@ -45,26 +45,26 @@ pub struct App<'a, 'v, 'ab, 'u> { version: Option<&'v str>, // A brief explaination of the program that gets displayed to the user when shown help/usage information about: Option<&'ab str>, - flags: HashMap<&'static str, FlagBuilder>, - opts: HashMap<&'static str, OptBuilder>, - positionals_idx: BTreeMap, - subcommands: HashMap>, + flags: HashMap<&'ar str, FlagBuilder<'ar>>, + opts: HashMap<&'ar str, OptBuilder<'ar>>, + positionals_idx: BTreeMap>, + subcommands: HashMap>, needs_long_help: bool, needs_long_version: bool, needs_short_help: bool, needs_short_version: bool, needs_subcmd_help: bool, - required: HashSet<&'static str>, - arg_list: HashSet<&'static str>, + required: HashSet<&'ar str>, + arg_list: HashSet<&'ar str>, short_list: HashSet, - long_list: HashSet<&'static str>, - blacklist: HashSet<&'static str>, + long_list: HashSet<&'ar str>, + blacklist: HashSet<&'ar str>, usage_str: Option<&'u str>, bin_name: Option } -impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ +impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{ /// Creates a new instance of an application requiring a name (such as the binary). Will be displayed /// to the user when they print version or help and usage information. /// @@ -75,7 +75,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// let prog = App::new("myprog") /// # .get_matches(); /// ``` - pub fn new<'n>(n: &'n str) -> App<'a, 'v, 'ab, 'u> { + pub fn new<'n>(n: &'n str) -> App<'a, 'v, 'ab, 'u, 'ar> { App { name: n.to_owned(), author: None, @@ -110,7 +110,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// .author("Kevin ") /// # .get_matches(); /// ``` - pub fn author(mut self, a: &'a str) -> App<'a, 'v, 'ab, 'u> { + pub fn author(mut self, a: &'a str) -> App<'a, 'v, 'ab, 'u, 'ar> { self.author = Some(a); self } @@ -125,7 +125,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// .about("Does really amazing things to great people") /// # .get_matches(); /// ``` - pub fn about(mut self, a: &'ab str) -> App<'a, 'v, 'ab, 'u > { + pub fn about(mut self, a: &'ab str) -> App<'a, 'v, 'ab, 'u, 'ar> { self.about = Some(a); self } @@ -140,7 +140,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// .version("v0.1.24") /// # .get_matches(); /// ``` - pub fn version(mut self, v: &'v str) -> App<'a, 'v, 'ab, 'u> { + pub fn version(mut self, v: &'v str) -> App<'a, 'v, 'ab, 'u, 'ar> { self.version = Some(v); self } @@ -162,7 +162,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// .usage("myapp [-clDas] ") /// # .get_matches(); /// ``` - pub fn usage(mut self, u: &'u str) -> App<'a, 'v, 'ab, 'u> { + pub fn usage(mut self, u: &'u str) -> App<'a, 'v, 'ab, 'u, 'ar> { self.usage_str = Some(u); self } @@ -180,7 +180,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// ) /// # .get_matches(); /// ``` - pub fn arg(mut self, a: Arg) -> App<'a, 'v, 'ab, 'u> { + pub fn arg<'l, 'h, 'b, 'r>(mut self, a: Arg<'ar, 'ar, 'ar, 'ar, 'ar>) -> App<'a, 'v, 'ab, 'u, 'ar> { if self.arg_list.contains(a.name) { panic!("Argument name must be unique, \"{}\" is already in use", a.name); } else { @@ -289,7 +289,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// Arg::new("debug").short("d")]) /// # .get_matches(); /// ``` - pub fn args(mut self, args: Vec) -> App<'a, 'v, 'ab, 'u> { + pub fn args(mut self, args: Vec>) -> App<'a, 'v, 'ab, 'u, 'ar> { for arg in args.into_iter() { self = self.arg(arg); } @@ -314,7 +314,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// // Additional subcommand configuration goes here, such as arguments... /// # .get_matches(); /// ``` - pub fn subcommand(mut self, subcmd: App<'a, 'v, 'ab, 'u>) -> App<'a, 'v, 'ab, 'u> { + pub fn subcommand(mut self, subcmd: App<'a, 'v, 'ab, 'u, 'ar>) -> App<'a, 'v, 'ab, 'u, 'ar> { if subcmd.name == "help" { self.needs_subcmd_help = false; } self.subcommands.insert(subcmd.name.clone(), subcmd); self @@ -333,7 +333,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ /// SubCommand::new("debug").about("Controls debug functionality")]) /// # .get_matches(); /// ``` - pub fn subcommands(mut self, subcmds: Vec>) -> App<'a, 'v, 'ab, 'u> { + pub fn subcommands(mut self, subcmds: Vec>) -> App<'a, 'v, 'ab, 'u, 'ar> { for subcmd in subcmds.into_iter() { self = self.subcommand(subcmd); } @@ -449,7 +449,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ if quit { env::set_exit_status(1); self.exit(); } } - pub fn get_matches(mut self) -> ArgMatches { + pub fn get_matches(mut self) -> ArgMatches<'ar> { let mut matches = ArgMatches::new(); let args = env::args().collect::>(); @@ -468,12 +468,12 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ matches } - fn get_matches_from(&mut self, matches: &mut ArgMatches, it: &mut IntoIter) { + fn get_matches_from(&mut self, matches: &mut ArgMatches<'ar>, it: &mut IntoIter) { self.create_help_and_version(); let mut pos_only = false; let mut subcmd_name: Option = None; - let mut needs_val_of: Option<&'static str> = None; + let mut needs_val_of: Option<&str> = None; let mut pos_counter = 1; while let Some(arg) = it.next() { let arg_slice = &arg[..]; @@ -518,14 +518,14 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ format!("Found positional argument {}, but {} doesn't accept any", arg, self.name), true, true); } - if let Some(ref p) = self.positionals_idx.get(&pos_counter) { + if let Some(p) = self.positionals_idx.get(&pos_counter) { if self.blacklist.contains(p.name) { self.report_error(format!("The argument \"{}\" is mutually exclusive with one or more other arguments", arg), true, true); } matches.positionals.insert(p.name, PosArg{ - name: p.name, + name: p.name.to_owned(), value: arg.clone(), }); @@ -616,7 +616,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ } } - fn parse_long_arg(&mut self, matches: &mut ArgMatches ,full_arg: &String) -> Option<&'static str> { + fn parse_long_arg(&mut self, matches: &mut ArgMatches<'ar> ,full_arg: &String) -> Option<&'ar str> { let mut arg = full_arg.trim_left_matches(|c| c == '-'); if arg == "help" && self.needs_long_help { @@ -656,7 +656,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ } } else { matches.opts.insert(v.name, OptArg{ - name: v.name, + name: v.name.to_owned(), occurrences: 1, values: if arg_val.is_some() { vec![arg_val.clone().unwrap()]} else {vec![]} }); @@ -706,7 +706,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ } if !done { matches.flags.insert(v.name, FlagArg{ - name: v.name, + name: v.name.to_owned(), occurrences: 1 }); } @@ -742,7 +742,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ unreachable!(); } - fn parse_short_arg(&mut self, matches: &mut ArgMatches ,full_arg: &String) -> Option<&'static str> { + fn parse_short_arg(&mut self, matches: &mut ArgMatches<'ar> ,full_arg: &String) -> Option<&'ar str> { let arg = &full_arg[..].trim_left_matches(|c| c == '-'); if arg.len() > 1 { // Multiple flags using short i.e. -bgHlS @@ -778,7 +778,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ } } else { matches.opts.insert(v.name, OptArg{ - name: v.name, + name: v.name.to_owned(), occurrences: 1, values: vec![] }); @@ -811,7 +811,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ unreachable!(); } - fn parse_single_short_flag(&mut self, matches: &mut ArgMatches, arg: char) -> bool { + fn parse_single_short_flag(&mut self, matches: &mut ArgMatches<'ar>, arg: char) -> bool { for v in self.flags.values().filter(|&v| v.short.is_some()).filter(|&v| v.short.unwrap() == arg) { // Ensure this flag isn't on the mutually excludes list if self.blacklist.contains(v.name) { @@ -831,7 +831,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ } if !done { matches.flags.insert(v.name, FlagArg{ - name: v.name, + name: v.name.to_owned(), occurrences: 1 }); } @@ -864,7 +864,7 @@ impl<'a, 'v, 'ab, 'u> App<'a, 'v, 'ab, 'u>{ false } - fn validate_blacklist(&self, matches: &ArgMatches) { + fn validate_blacklist(&self, matches: &ArgMatches<'ar>) { for name in self.blacklist.iter() { if matches.flags.contains_key(name) { self.report_error(format!("The argument {} is mutually exclusive with one or more other arguments", diff --git a/src/args/arg.rs b/src/args/arg.rs index 16d7d6f590d..ff3500f2044 100644 --- a/src/args/arg.rs +++ b/src/args/arg.rs @@ -18,18 +18,18 @@ /// .takes_value(true) /// .help("Provides a config file to myprog") /// # ).get_matches(); -pub struct Arg { +pub struct Arg<'n, 'l, 'h, 'b, 'r> { /// The unique name of the argument, required - pub name: &'static str, + pub name: &'n str, /// The short version (i.e. single character) of the argument, no preceding `-` /// **NOTE:** `short` is mutually exclusive with `index` pub short: Option, /// The long version of the flag (i.e. word) without the preceding `--` /// **NOTE:** `long` is mutually exclusive with `index` - pub long: Option<&'static str>, + pub long: Option<&'l str>, /// The string of text that will displayed to the user when the application's /// `help` text is displayed - pub help: Option<&'static str>, + pub help: Option<&'h 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 @@ -46,13 +46,13 @@ pub struct Arg { /// I.e. `-v -v -v` or `-vvv` pub multiple: bool, /// A list of names for other arguments that *may not* be used with this flag - pub blacklist: Option>, + pub blacklist: Option>, /// A list of names of other arguments that are *required* to be used when /// this flag is used - pub requires: Option> + pub requires: Option> } -impl Arg { +impl<'n, 'l, 'h, 'b, 'r> Arg<'n, 'l, 'h, 'b, 'r> { /// Creates a new instace of `Arg` using a unique string name. /// The name will be used by the library consumer to get information about /// whether or not the argument was used at runtime. @@ -70,7 +70,7 @@ impl Arg { /// Arg::new("conifg") /// # .short("c") /// # ).get_matches(); - pub fn new(n: &'static str) -> Arg { + pub fn new(n: &'n str) -> Arg<'n, 'l, 'h, 'b, 'r> { Arg { name: n, short: None, @@ -104,7 +104,7 @@ impl Arg { /// # Arg::new("conifg") /// .short("c") /// # ).get_matches(); - pub fn short(mut self, s: &'static str) -> Arg { + pub fn short(mut self, s: &str) -> Arg<'n, 'l, 'h, 'b, 'r> { self.short = s.trim_left_matches(|c| c == '-').chars().nth(0); self } @@ -128,7 +128,7 @@ impl Arg { /// # Arg::new("conifg") /// .long("config") /// # ).get_matches(); - pub fn long(mut self, l: &'static str) -> Arg { + pub fn long(mut self, l: &'l str) -> Arg<'n, 'l, 'h, 'b, 'r> { self.long = Some(l.trim_left_matches(|c| c == '-')); self } @@ -145,7 +145,7 @@ impl Arg { /// # Arg::new("conifg") /// .help("The config file used by the myprog") /// # ).get_matches(); - pub fn help(mut self, h: &'static str) -> Arg { + pub fn help(mut self, h: &'h str) -> Arg<'n, 'l, 'h, 'b, 'r> { self.help = Some(h); self } @@ -168,7 +168,7 @@ impl Arg { /// # Arg::new("conifg") /// .required(true) /// # ).get_matches(); - pub fn required(mut self, r: bool) -> Arg { + pub fn required(mut self, r: bool) -> Arg<'n, 'l, 'h, 'b, 'r> { self.required = r; self } @@ -187,7 +187,7 @@ impl Arg { /// # let myprog = App::new("myprog").arg(Arg::new("conifg") /// .mutually_excludes("debug") /// # ).get_matches(); - pub fn mutually_excludes(mut self, name: &'static str) -> Arg { + pub fn mutually_excludes(mut self, name: &'b str) -> Arg<'n, 'l, 'h, 'b, 'r> { if let Some(ref mut vec) = self.blacklist { vec.push(name); } else { @@ -211,7 +211,7 @@ impl Arg { /// .mutually_excludes_all( /// vec!["debug", "input"]) /// # ).get_matches(); - pub fn mutually_excludes_all(mut self, names: Vec<&'static str>) -> Arg { + pub fn mutually_excludes_all(mut self, names: Vec<&'b str>) -> Arg<'n, 'l, 'h, 'b, 'r> { if let Some(ref mut vec) = self.blacklist { for n in names { vec.push(n); @@ -234,7 +234,7 @@ impl Arg { /// # let myprog = App::new("myprog").arg(Arg::new("conifg") /// .requires("debug") /// # ).get_matches(); - pub fn requires(mut self, name: &'static str) -> Arg { + pub fn requires(mut self, name: &'r str) -> Arg<'n, 'l, 'h, 'b, 'r> { if let Some(ref mut vec) = self.requires { vec.push(name); } else { @@ -257,7 +257,7 @@ impl Arg { /// .requires_all( /// vec!["debug", "input"]) /// # ).get_matches(); - pub fn requires_all(mut self, names: Vec<&'static str>) -> Arg { + pub fn requires_all(mut self, names: Vec<&'r str>) -> Arg<'n, 'l, 'h, 'b, 'r> { if let Some(ref mut vec) = self.requires { for n in names { vec.push(n); @@ -282,7 +282,7 @@ impl Arg { /// # Arg::new("conifg") /// .takes_value(true) /// # ).get_matches(); - pub fn takes_value(mut self, tv: bool) -> Arg { + pub fn takes_value(mut self, tv: bool) -> Arg<'n, 'l, 'h, 'b, 'r> { self.takes_value = tv; self } @@ -303,7 +303,7 @@ impl Arg { /// # Arg::new("conifg") /// .index(1) /// # ).get_matches(); - pub fn index(mut self, idx: u8) -> Arg { + pub fn index(mut self, idx: u8) -> Arg<'n, 'l, 'h, 'b, 'r> { self.index = Some(idx); self } @@ -325,7 +325,7 @@ impl Arg { /// # Arg::new("debug") /// .multiple(true) /// # ).get_matches(); - pub fn multiple(mut self, multi: bool) -> Arg { + pub fn multiple(mut self, multi: bool) -> Arg<'n, 'l, 'h, 'b, 'r> { self.multiple = multi; self } diff --git a/src/args/argmatches.rs b/src/args/argmatches.rs index 254c404f635..06462e3af47 100644 --- a/src/args/argmatches.rs +++ b/src/args/argmatches.rs @@ -59,15 +59,15 @@ use args::posarg::PosArg; /// println!("Not printing testing lists..."); /// } /// } -pub struct ArgMatches { +pub struct ArgMatches<'a> { // pub matches_of: &'static str, - pub flags: HashMap<&'static str, FlagArg>, - pub opts: HashMap<&'static str, OptArg>, - pub positionals: HashMap<&'static str, PosArg>, - pub subcommand: Option> + pub flags: HashMap<&'a str, FlagArg>, + pub opts: HashMap<&'a str, OptArg>, + pub positionals: HashMap<&'a str, PosArg>, + pub subcommand: Option>> } -impl ArgMatches { +impl<'a> ArgMatches<'a> { /// Creates a new instance of `ArgMatches`. This ins't called directly, but /// through the `.get_matches()` method of `App` /// @@ -77,7 +77,7 @@ impl ArgMatches { /// # use clap::{App, Arg}; /// let matches = App::new("myprog").get_matches(); /// ``` - pub fn new() -> ArgMatches { + pub fn new() -> ArgMatches<'a> { ArgMatches { // matches_of: name, flags: HashMap::new(), @@ -103,7 +103,7 @@ impl ArgMatches { /// println!("Value for output: {}", o); /// } /// ``` - pub fn value_of(&self, name: &'static str) -> Option<&str> { + pub fn value_of<'n>(&self, name: &'n str) -> Option<&str> { if let Some(ref opt) = self.opts.get(name) { if !opt.values.is_empty() { if let Some(ref s) = opt.values.iter().nth(0) { @@ -135,7 +135,7 @@ impl ArgMatches { /// } /// } /// ``` - pub fn values_of(&self, name: &'static str) -> Option> { + pub fn values_of<'n>(&self, name: &'n str) -> Option> { if let Some(ref opt) = self.opts.get(name) { if opt.values.is_empty() { return None; } @@ -157,7 +157,7 @@ impl ArgMatches { /// println!("The output argument was used!"); /// } /// ``` - pub fn is_present(&self, name: &'static str) -> bool { + pub fn is_present<'n>(&self, name: &'n str) -> bool { if let Some(ref sc) = self.subcommand { if sc.name == name { return true; } } @@ -186,7 +186,7 @@ impl ArgMatches { /// println!("Debug mode kind of on"); /// } /// ``` - pub fn occurrences_of(&self, name: &'static str) -> u8 { + pub fn occurrences_of<'n>(&self, name: &'n str) -> u8 { if let Some(ref f) = self.flags.get(name) { return f.occurrences; } @@ -208,7 +208,7 @@ impl ArgMatches { /// // Use matches as normal /// } /// ``` - pub fn subcommand_matches(&self, name: &'static str) -> Option<&ArgMatches> { + pub fn subcommand_matches<'n>(&self, name: &'n str) -> Option<&ArgMatches> { if let Some( ref sc) = self.subcommand { if sc.name != name { return None; } return Some(&sc.matches); diff --git a/src/args/flagarg.rs b/src/args/flagarg.rs index 3ae9a51eb4c..b466e18642f 100644 --- a/src/args/flagarg.rs +++ b/src/args/flagarg.rs @@ -8,36 +8,35 @@ /// ```sh /// $ myprog -a --some /// ``` -#[derive(Copy)] pub struct FlagArg { /// The unique name of the argument, required - pub name: &'static str, + pub name: String, /// How many occurences of this flag have been /// found when parsing pub occurrences: u8 } -pub struct FlagBuilder { - pub name: &'static str, +pub struct FlagBuilder<'n> { + pub name: &'n str, + /// The long version of the flag (i.e. word) + /// without the preceding `--` + pub long: Option<&'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>, /// Determines if multiple instances of the same /// flag are allowed /// I.e. `-v -v -v` or `-vvv` pub multiple: bool, /// A list of names for other arguments that /// *may not* be used with this flag - pub blacklist: Option>, + pub blacklist: Option>, /// A list of names of other arguments that /// are *required* to be used when this /// flag is used - pub requires: Option>, + pub requires: Option>, /// The short version (i.e. single character) /// of the argument, no preceding `-` pub short: Option, - /// The long version of the flag (i.e. word) - /// without the preceding `--` - pub long: Option<&'static str>, - /// The string of text that will displayed to - /// the user when the application's `help` - /// text is displayed - pub help: Option<&'static str>, } \ No newline at end of file diff --git a/src/args/optarg.rs b/src/args/optarg.rs index 0eef3ae5cbb..d82b1711499 100644 --- a/src/args/optarg.rs +++ b/src/args/optarg.rs @@ -13,26 +13,26 @@ /// **NOTE:** The long version may also use the `--argument=value` version too pub struct OptArg { /// The unique name of the argument, required - pub name: &'static str, + pub name: String, /// How many occurences of this option have been found when parsing pub occurrences: u8, /// The value provided to the argument by the user pub values: Vec } -pub struct OptBuilder { - pub name: &'static str, - /// Allow multiple occurrences of an option argument such as "-c some -c other" - pub multiple: bool, - /// A list of names for other arguments that *may not* be used with this flag - pub blacklist: Option>, +pub struct OptBuilder<'n> { + pub name: &'n str, /// The short version (i.e. single character) of the argument, no preceding `-` pub short: Option, /// The long version of the flag (i.e. word) without the preceding `--` - pub long: Option<&'static str>, + pub long: Option<&'n str>, /// The string of text that will displayed to the user when the application's /// `help` text is displayed - pub help: Option<&'static str>, + pub help: Option<&'n str>, + /// Allow multiple occurrences of an option argument such as "-c some -c other" + pub multiple: bool, + /// A list of names for other arguments that *may not* be used with this flag + pub blacklist: Option>, /// 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 @@ -40,5 +40,5 @@ pub struct OptBuilder { pub required: bool, /// A list of names of other arguments that are *required* to be used when /// this flag is used - pub requires: Option>, + pub requires: Option>, } diff --git a/src/args/posarg.rs b/src/args/posarg.rs index 33e3815d505..ef7d619bbc2 100644 --- a/src/args/posarg.rs +++ b/src/args/posarg.rs @@ -13,16 +13,16 @@ /// **NOTE:** The index starts at `1` **NOT** `0` pub struct PosArg { /// The unique name of the argument, required - pub name: &'static str, + pub name: String, /// The value provided to the argument by the user pub value: String, } -pub struct PosBuilder { - pub name: &'static str, +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<&'static str>, + 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 @@ -30,9 +30,9 @@ pub struct PosBuilder { pub required: bool, /// A list of names of other arguments that are *required* to be used when /// this flag is used - pub requires: Option>, + pub requires: Option>, /// A list of names for other arguments that *may not* be used with this flag - pub blacklist: Option>, + pub blacklist: Option>, /// The index of the argument pub index: u8 } \ No newline at end of file diff --git a/src/args/subcommand.rs b/src/args/subcommand.rs index bf57bb883ac..a9dcd3644c2 100644 --- a/src/args/subcommand.rs +++ b/src/args/subcommand.rs @@ -20,12 +20,12 @@ use ArgMatches; /// .help("The configuration file to use") /// .index(1)) /// # ).get_matches(); -pub struct SubCommand { +pub struct SubCommand<'a> { pub name: String, - pub matches: ArgMatches + pub matches: ArgMatches<'a> } -impl SubCommand { +impl<'a> SubCommand<'a> { /// Creates a new instance of a subcommand requiring a name. Will be displayed /// to the user when they print version or help and usage information. /// @@ -37,7 +37,7 @@ impl SubCommand { /// SubCommand::new("config") /// # ).get_matches(); /// ``` - pub fn new<'a, 'v, 'ab, 'u>(name: &'a str) -> App<'a, 'v, 'ab, 'u> { + pub fn new<'n, 'au, 'v, 'ab, 'u, 'ar>(name: &'n str) -> App<'au, 'v, 'ab, 'u, 'ar> { App::new(name) } } \ No newline at end of file