diff --git a/.travis.yml b/.travis.yml index f115e505..e34d02cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: rust cache: cargo rust: + - 1.21.0 - stable - beta - nightly diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a9c3902..26413208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v0.2.10 (2018-06-07) + +* 1.21.0 is the minimum required rustc version by + [@TeXitoi](https://github.com/TeXitoi) + # v0.2.9 (2018-06-05) * Fix a bug when using `flatten` by diff --git a/Cargo.toml b/Cargo.toml index 7cc6355c..91bdbb68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "structopt" -version = "0.2.9" +version = "0.2.10" authors = ["Guillaume Pinot ", "others"] description = "Parse command line argument by defining a struct." documentation = "https://docs.rs/structopt" @@ -27,6 +27,6 @@ travis-ci = { repository = "TeXitoi/structopt" } [dependencies] clap = { version = "2.20", default-features = false } -structopt-derive = { path = "structopt-derive", version = "0.2.9" } +structopt-derive = { path = "structopt-derive", version = "0.2.10" } [workspace] diff --git a/README.md b/README.md index 7e038f51..7b4fb36b 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,12 @@ $ ./basic -o foo.txt -dvvvs 1337 -l alice -l bob --nb-cars 4 bar.txt baz.txt Opt { debug: true, verbose: 3, speed: 1337, output: "foo.txt", nb_cars: Some(4), level: ["alice", "bob"], files: ["bar.txt", "baz.txt"] } ``` +## StructOpt rustc version policy + +- Minimum rustc version modification must be specified in the [changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) and in the [travis configuration](https://github.com/TeXitoi/structopt/blob/master/.travis.yml). +- Contributors can increment minimum rustc version without any justification if the new version is required by the latest version of one of StructOpt's depedencies (`cargo update` will not fail on StructOpt). +- Contributors can increment minimum rustc version if the library user experience is improved. + ## Why I use [docopt](https://crates.io/crates/docopt) since a long time (pre rust 1.0). I really like the fact that you have a structure with the parsed argument: no need to convert `String` to `f64`, no useless `unwrap`. But on the other hand, I don't like to write by hand the usage string. That's like going back to the golden age of WYSIWYG editors. Field naming is also a bit artificial. diff --git a/structopt-derive/Cargo.toml b/structopt-derive/Cargo.toml index dc641ca2..5d294122 100644 --- a/structopt-derive/Cargo.toml +++ b/structopt-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "structopt-derive" -version = "0.2.9" +version = "0.2.10" authors = ["Guillaume Pinot "] description = "Parse command line argument by defining a struct, derive crate." documentation = "https://docs.rs/structopt-derive" diff --git a/structopt-derive/src/attrs.rs b/structopt-derive/src/attrs.rs index 4089b44d..aed307af 100644 --- a/structopt-derive/src/attrs.rs +++ b/structopt-derive/src/attrs.rs @@ -108,7 +108,7 @@ impl Attrs { ref tokens => panic!("unsupported syntax: {}", quote!(#tokens).to_string()), }); for attr in iter { - match &attr { + match attr { NameValue(MetaNameValue { ident, lit: Str(value), @@ -118,14 +118,21 @@ impl Attrs { name: ident.to_string(), args: quote!(#lit), }), - List(MetaList { ident, nested, .. }) if ident == "parse" => { + List(MetaList { + ref ident, + ref nested, + .. + }) if ident == "parse" => + { if nested.len() != 1 { panic!("parse must have exactly one argument"); } self.has_custom_parser = true; - self.parser = match &nested[0] { + self.parser = match nested[0] { Meta(NameValue(MetaNameValue { - ident, lit: Str(v), .. + ref ident, + lit: Str(ref v), + .. })) => { let function: syn::Path = v.parse().expect("parser function path"); let parser = ident.to_string().parse().unwrap(); @@ -149,13 +156,17 @@ impl Attrs { }; } List(MetaList { - ident, ref nested, .. + ref ident, + ref nested, + .. }) if ident == "raw" => { for method in nested { - match method { + match *method { Meta(NameValue(MetaNameValue { - ident, lit: Str(v), .. + ref ident, + lit: Str(ref v), + .. })) => self.push_raw_method(&ident.to_string(), v), ref mi @ _ => panic!("unsupported raw entry: {}", quote!(#mi)), } diff --git a/tests/arguments.rs b/tests/arguments.rs index 5c3bc432..47b57f4c 100644 --- a/tests/arguments.rs +++ b/tests/arguments.rs @@ -106,6 +106,6 @@ fn arguments_safe() { assert_eq!( clap::ErrorKind::ValueValidation, - Opt::from_iter_safe(&["test", "NOPE"]).err().unwrap().kind, + Opt::from_iter_safe(&["test", "NOPE"]).err().unwrap().kind ); } diff --git a/tests/custom-string-parsers.rs b/tests/custom-string-parsers.rs index 92e1dd8a..738f3e21 100644 --- a/tests/custom-string-parsers.rs +++ b/tests/custom-string-parsers.rs @@ -231,7 +231,7 @@ fn test_custom_bool() { tribool: None, bitset: vec![], }, - Opt::from_iter(&["test", "-dfalse"]), + Opt::from_iter(&["test", "-dfalse"]) ); assert_eq!( Opt { @@ -240,7 +240,7 @@ fn test_custom_bool() { tribool: None, bitset: vec![], }, - Opt::from_iter(&["test", "-dtrue"]), + Opt::from_iter(&["test", "-dtrue"]) ); assert_eq!( Opt { @@ -249,7 +249,7 @@ fn test_custom_bool() { tribool: None, bitset: vec![], }, - Opt::from_iter(&["test", "-dtrue", "-vfalse"]), + Opt::from_iter(&["test", "-dtrue", "-vfalse"]) ); assert_eq!( Opt { @@ -258,7 +258,7 @@ fn test_custom_bool() { tribool: None, bitset: vec![], }, - Opt::from_iter(&["test", "-dtrue", "-vtrue"]), + Opt::from_iter(&["test", "-dtrue", "-vtrue"]) ); assert_eq!( Opt { @@ -267,7 +267,7 @@ fn test_custom_bool() { tribool: Some(false), bitset: vec![], }, - Opt::from_iter(&["test", "-dtrue", "-tfalse"]), + Opt::from_iter(&["test", "-dtrue", "-tfalse"]) ); assert_eq!( Opt { @@ -276,7 +276,7 @@ fn test_custom_bool() { tribool: Some(true), bitset: vec![], }, - Opt::from_iter(&["test", "-dtrue", "-ttrue"]), + Opt::from_iter(&["test", "-dtrue", "-ttrue"]) ); assert_eq!( Opt { @@ -285,6 +285,6 @@ fn test_custom_bool() { tribool: None, bitset: vec![false, true, false, false], }, - Opt::from_iter(&["test", "-dtrue", "-bfalse", "-btrue", "-bfalse", "-bfalse"]), + Opt::from_iter(&["test", "-dtrue", "-bfalse", "-btrue", "-bfalse", "-bfalse"]) ); }