Add a minimum rustc version policy (#116)

Fix #115
This commit is contained in:
Guillaume P 2018-06-07 15:04:37 +02:00 committed by GitHub
parent de7fc7a08e
commit 18192d8e50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 18 deletions

View file

@ -1,6 +1,7 @@
language: rust
cache: cargo
rust:
- 1.21.0
- stable
- beta
- nightly

View file

@ -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

View file

@ -1,6 +1,6 @@
[package]
name = "structopt"
version = "0.2.9"
version = "0.2.10"
authors = ["Guillaume Pinot <texitoi@texitoi.eu>", "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]

View file

@ -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.

View file

@ -1,6 +1,6 @@
[package]
name = "structopt-derive"
version = "0.2.9"
version = "0.2.10"
authors = ["Guillaume Pinot <texitoi@texitoi.eu>"]
description = "Parse command line argument by defining a struct, derive crate."
documentation = "https://docs.rs/structopt-derive"

View file

@ -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)),
}

View file

@ -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
);
}

View file

@ -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"])
);
}