mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Fix #66
This commit is contained in:
parent
615a8d324e
commit
12acd6121a
5 changed files with 21 additions and 6 deletions
|
@ -1,7 +1,11 @@
|
|||
# v0.2.2 (2018-02-12)
|
||||
|
||||
* Fix [#66](https://github.com/TeXitoi/structopt/issues/66) by [@TeXitoi](https://github.com/TeXitoi)
|
||||
|
||||
# v0.2.1 (2018-02-11)
|
||||
|
||||
* Fix a bug around enum tuple and the about message in the global help by [@TeXitoi](https://github.com/TeXitoi)
|
||||
* Fix #65 by [@TeXitoi](https://github.com/TeXitoi)
|
||||
* Fix [#65](https://github.com/TeXitoi/structopt/issues/65) by [@TeXitoi](https://github.com/TeXitoi)
|
||||
|
||||
# v0.2.0 (2018-02-10)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "structopt"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Guillaume Pinot <texitoi@texitoi.eu>"]
|
||||
description = "Parse command line argument by defining a struct."
|
||||
documentation = "https://docs.rs/structopt"
|
||||
|
@ -18,6 +18,6 @@ travis-ci = { repository = "TeXitoi/structopt" }
|
|||
|
||||
[dependencies]
|
||||
clap = { version = "2.20", default-features = false }
|
||||
structopt-derive = { path = "structopt-derive", version = "0.2.1" }
|
||||
structopt-derive = { path = "structopt-derive", version = "0.2.2" }
|
||||
|
||||
[workspace]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "structopt-derive"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Guillaume Pinot <texitoi@texitoi.eu>"]
|
||||
description = "Parse command line argument by defining a struct, derive crate."
|
||||
documentation = "https://docs.rs/structopt-derive"
|
||||
|
|
|
@ -56,11 +56,11 @@ impl Attrs {
|
|||
}
|
||||
fn push_str_method(&mut self, name: &str, arg: &str) {
|
||||
match (name, arg) {
|
||||
(name, "") => {
|
||||
("about", "") | ("version", "") | ("author", "") => {
|
||||
let methods = mem::replace(&mut self.methods, vec![]);
|
||||
self.methods = methods
|
||||
.into_iter()
|
||||
.filter(|m| m.name == name)
|
||||
.filter(|m| m.name != name)
|
||||
.collect();
|
||||
}
|
||||
("name", new_name) => self.name = new_name.into(),
|
||||
|
|
|
@ -83,3 +83,14 @@ fn options() {
|
|||
assert_eq!(Opt { arg: vec![24, 42] },
|
||||
Opt::from_clap(&Opt::clap().get_matches_from(&["test", "-a24", "--arg", "42"])));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empy_default_value() {
|
||||
#[derive(StructOpt, PartialEq, Debug)]
|
||||
struct Opt {
|
||||
#[structopt(short = "a", default_value = "")]
|
||||
arg: String,
|
||||
}
|
||||
assert_eq!(Opt { arg: "".into() }, Opt::from_iter(&["test"]));
|
||||
assert_eq!(Opt { arg: "foo".into() }, Opt::from_iter(&["test", "-afoo"]));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue