aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-09-23 15:25:52 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-09-23 15:25:52 +0000
commita66c8fc1f61f2b701957ac67346e55b7ce702cec (patch)
tree67d12643bde23f5575ac43a9cfdcd606af977b83
parentf177e15808fb81999705d9b9d582d8e17d223037 (diff)
parent564ec877d7dcf8864e765b3af8bacd845233a945 (diff)
downloadstructopt-a66c8fc1f61f2b701957ac67346e55b7ce702cec.tar.gz
Upgrade rust/crates/structopt to 0.3.23 am: 3a84c421cd am: 40524edf47 am: 8a70417263 am: 7e6de8f803 am: 564ec877d7
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/structopt/+/1833620 Change-Id: Idbed23e28436057737ad080cd3ae0e7a33534aae
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--.travis.yml2
-rw-r--r--Android.bp24
-rw-r--r--CHANGELOG.md6
-rw-r--r--Cargo.toml6
-rw-r--r--Cargo.toml.orig6
-rw-r--r--METADATA8
-rw-r--r--README.md2
-rw-r--r--examples/true_or_false.rs2
-rw-r--r--src/lib.rs2
-rw-r--r--tests/custom-string-parsers.rs6
-rw-r--r--tests/generics.rs118
-rw-r--r--tests/issues.rs29
-rw-r--r--tests/macro-errors.rs2
-rw-r--r--tests/non_literal_attributes.rs6
-rw-r--r--tests/special_types.rs2
-rw-r--r--tests/subcommands.rs46
-rw-r--r--tests/ui/non_existent_attr.stderr2
-rw-r--r--tests/ui/tuple_struct.stderr2
19 files changed, 174 insertions, 99 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 887fa2d..0057313 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "004cfc218e7fbfdbecc4088f9e3fa5061f36cb4d"
+ "sha1": "88e5402df017c052f1524f293b2e13bd01810819"
}
}
diff --git a/.travis.yml b/.travis.yml
index 14f5a6c..7b4fcc9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ matrix:
before_script: rustup component add clippy
script: cargo clippy --all -- -D warnings
- - rust: 1.36.0
+ - rust: 1.46.0
- rust: stable
- rust: beta
- rust: nightly
diff --git a/Android.bp b/Android.bp
index 3051273..ff4330f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -41,6 +41,8 @@ rust_library {
name: "libstructopt",
host_supported: true,
crate_name: "structopt",
+ cargo_env_compat: true,
+ cargo_pkg_version: "0.3.23",
srcs: ["src/lib.rs"],
edition: "2018",
features: ["default"],
@@ -54,25 +56,3 @@ rust_library {
"com.android.virt",
],
}
-
-// dependent_library ["feature_list"]
-// ansi_term-0.11.0
-// atty-0.2.14
-// bitflags-1.2.1 "default"
-// clap-2.33.3 "ansi_term,atty,color,default,strsim,suggestions,vec_map"
-// heck-0.3.3
-// lazy_static-1.4.0
-// libc-0.2.98
-// proc-macro-error-1.0.4 "default,syn,syn-error"
-// proc-macro-error-attr-1.0.4
-// proc-macro2-1.0.28 "default,proc-macro"
-// quote-1.0.9 "default,proc-macro"
-// strsim-0.8.0
-// structopt-derive-0.4.15
-// syn-1.0.74 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote"
-// textwrap-0.11.0
-// unicode-segmentation-1.8.0
-// unicode-width-0.1.8 "default"
-// unicode-xid-0.2.2 "default"
-// vec_map-0.8.2
-// version_check-0.9.3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 117ef2d..cdf1ba7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# v0.3.23 (2021-08-30)
+
+* Update minimal rust version to 1.46 because of bitflags 1.3
+* Fixed [a bug that occurs when the type of `map` becomes ambiguous](https://github.com/TeXitoi/structopt/issues/490).
+* Add support for [skip for enum variant subcommands](https://github.com/TeXitoi/structopt/issues/493)
+
# v0.3.22 (2021-07-04)
* Add support for [generics in derive](https://github.com/TeXitoi/structopt/issues/128)
diff --git a/Cargo.toml b/Cargo.toml
index 260ef4a..ba91744 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "structopt"
-version = "0.3.22"
+version = "0.3.23"
authors = ["Guillaume Pinot <texitoi@texitoi.eu>", "others"]
description = "Parse command line argument by defining a struct."
documentation = "https://docs.rs/structopt"
@@ -35,12 +35,12 @@ optional = true
package = "paw"
[dependencies.structopt-derive]
-version = "=0.4.15"
+version = "=0.4.16"
[dev-dependencies.rustversion]
version = "1"
[dev-dependencies.strum]
-version = "0.20"
+version = "0.21"
features = ["derive"]
[dev-dependencies.trybuild]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index d45ecac..bccc07f 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "structopt"
-version = "0.3.22"
+version = "0.3.23"
edition = "2018"
authors = ["Guillaume Pinot <texitoi@texitoi.eu>", "others"]
description = "Parse command line argument by defining a struct."
@@ -28,11 +28,11 @@ travis-ci = { repository = "TeXitoi/structopt" }
[dependencies]
clap = { version = "2.33", default-features = false }
-structopt-derive = { path = "structopt-derive", version = "=0.4.15" }
+structopt-derive = { path = "structopt-derive", version = "=0.4.16" }
lazy_static = "1.4.0"
paw_dep = { version = "1", optional = true, package = "paw" }
[dev-dependencies]
trybuild = { version = "1.0.5", features = ["diff"] }
rustversion = "1"
-strum = { version = "0.20", features = ["derive"] }
+strum = { version = "0.21", features = ["derive"] }
diff --git a/METADATA b/METADATA
index 40329f0..4f3ccd1 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/structopt/structopt-0.3.22.crate"
+ value: "https://static.crates.io/crates/structopt/structopt-0.3.23.crate"
}
- version: "0.3.22"
+ version: "0.3.23"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 8
- day: 9
+ month: 9
+ day: 22
}
}
diff --git a/README.md b/README.md
index 6609488..dfb2059 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# StructOpt
-[![Build status](https://travis-ci.org/TeXitoi/structopt.svg?branch=master)](https://travis-ci.org/TeXitoi/structopt) [![](https://img.shields.io/crates/v/structopt.svg)](https://crates.io/crates/structopt) [![](https://docs.rs/structopt/badge.svg)](https://docs.rs/structopt)
+[![Build status](https://travis-ci.com/TeXitoi/structopt.svg?branch=master)](https://app.travis-ci.com/github/TeXitoi/structopt) [![](https://img.shields.io/crates/v/structopt.svg)](https://crates.io/crates/structopt) [![](https://docs.rs/structopt/badge.svg)](https://docs.rs/structopt)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
Parse command line arguments by defining a struct. It combines [clap](https://crates.io/crates/clap) with custom derive.
diff --git a/examples/true_or_false.rs b/examples/true_or_false.rs
index 31a543e..814f3d8 100644
--- a/examples/true_or_false.rs
+++ b/examples/true_or_false.rs
@@ -23,7 +23,7 @@ struct Opt {
bar: bool,
// `bool` can be positional only with explicit `parse(...)` annotation
- #[structopt(long, parse(try_from_str))]
+ #[structopt(parse(try_from_str))]
boom: bool,
}
diff --git a/src/lib.rs b/src/lib.rs
index b6e6b73..f7c5ce7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1089,8 +1089,6 @@
//! }
//! ```
-
-
// those mains are for a reason
#![allow(clippy::needless_doctest_main)]
diff --git a/tests/custom-string-parsers.rs b/tests/custom-string-parsers.rs
index 89070ed..8fe055b 100644
--- a/tests/custom-string-parsers.rs
+++ b/tests/custom-string-parsers.rs
@@ -76,7 +76,11 @@ fn test_parse_hex() {
let err = HexOpt::clap()
.get_matches_from_safe(&["test", "-n", "gg"])
.unwrap_err();
- assert!(err.message.contains("invalid digit found in string"), err);
+ assert!(
+ err.message.contains("invalid digit found in string"),
+ "{}",
+ err
+ );
}
fn custom_parser_1(_: &str) -> &'static str {
diff --git a/tests/generics.rs b/tests/generics.rs
index 896f98a..0da349b 100644
--- a/tests/generics.rs
+++ b/tests/generics.rs
@@ -1,137 +1,145 @@
-
use structopt::StructOpt;
#[test]
fn generic_struct_flatten() {
-
- #[derive(StructOpt,PartialEq,Debug)]
- struct Inner{
- pub answer: isize
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Inner {
+ pub answer: isize,
}
- #[derive(StructOpt,PartialEq,Debug)]
- struct Outer<T:StructOpt>{
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Outer<T: StructOpt> {
#[structopt(flatten)]
- pub inner: T
+ pub inner: T,
}
assert_eq!(
- Outer{inner: Inner{ answer: 42 }},
- Outer::from_iter(&[ "--answer", "42" ])
+ Outer {
+ inner: Inner { answer: 42 }
+ },
+ Outer::from_iter(&["--answer", "42"])
)
}
#[test]
fn generic_struct_flatten_w_where_clause() {
-
- #[derive(StructOpt,PartialEq,Debug)]
- struct Inner{
- pub answer: isize
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Inner {
+ pub answer: isize,
}
- #[derive(StructOpt,PartialEq,Debug)]
- struct Outer<T> where T:StructOpt {
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Outer<T>
+ where
+ T: StructOpt,
+ {
#[structopt(flatten)]
- pub inner: T
+ pub inner: T,
}
assert_eq!(
- Outer{inner: Inner{ answer: 42 }},
- Outer::from_iter(&[ "--answer", "42" ])
+ Outer {
+ inner: Inner { answer: 42 }
+ },
+ Outer::from_iter(&["--answer", "42"])
)
}
#[test]
fn generic_enum() {
-
- #[derive(StructOpt,PartialEq,Debug)]
- struct Inner{
- pub answer: isize
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Inner {
+ pub answer: isize,
}
- #[derive(StructOpt,PartialEq,Debug)]
+ #[derive(StructOpt, PartialEq, Debug)]
enum GenericEnum<T: StructOpt> {
-
Start(T),
Stop,
}
assert_eq!(
- GenericEnum::Start(Inner{answer: 42}),
- GenericEnum::from_iter(&[ "test", "start", "42" ])
+ GenericEnum::Start(Inner { answer: 42 }),
+ GenericEnum::from_iter(&["test", "start", "42"])
)
-
}
#[test]
fn generic_enum_w_where_clause() {
-
- #[derive(StructOpt,PartialEq,Debug)]
- struct Inner{
- pub answer: isize
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Inner {
+ pub answer: isize,
}
- #[derive(StructOpt,PartialEq,Debug)]
- enum GenericEnum<T> where T: StructOpt {
-
+ #[derive(StructOpt, PartialEq, Debug)]
+ enum GenericEnum<T>
+ where
+ T: StructOpt,
+ {
Start(T),
Stop,
}
assert_eq!(
- GenericEnum::Start(Inner{answer: 42}),
- GenericEnum::from_iter(&[ "test", "start", "42" ])
+ GenericEnum::Start(Inner { answer: 42 }),
+ GenericEnum::from_iter(&["test", "start", "42"])
)
-
}
#[test]
fn generic_w_fromstr_trait_bound() {
-
use std::{fmt, str::FromStr};
- #[derive(StructOpt,PartialEq,Debug)]
- struct Opt<T> where T:FromStr, <T as FromStr>::Err: fmt::Debug + fmt::Display
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Opt<T>
+ where
+ T: FromStr,
+ <T as FromStr>::Err: fmt::Debug + fmt::Display,
{
- answer: T
+ answer: T,
}
assert_eq!(
- Opt::<isize>{answer:42},
- Opt::<isize>::from_iter([& "--answer", "42" ])
+ Opt::<isize> { answer: 42 },
+ Opt::<isize>::from_iter(&["--answer", "42"])
)
}
#[test]
fn generic_wo_trait_bound() {
-
use std::time::Duration;
- #[derive(StructOpt,PartialEq,Debug)]
+ #[derive(StructOpt, PartialEq, Debug)]
struct Opt<T> {
answer: isize,
#[structopt(skip)]
- took: Option<T>
+ took: Option<T>,
}
assert_eq!(
- Opt::<Duration>{answer:42,took:None},
- Opt::<Duration>::from_iter([& "--answer", "42" ])
+ Opt::<Duration> {
+ answer: 42,
+ took: None
+ },
+ Opt::<Duration>::from_iter(&["--answer", "42"])
)
}
#[test]
fn generic_where_clause_w_trailing_comma() {
-
use std::{fmt, str::FromStr};
- #[derive(StructOpt,PartialEq,Debug)]
- struct Opt<T> where T:FromStr, <T as FromStr>::Err: fmt::Debug + fmt::Display {
- pub answer: T
+ #[derive(StructOpt, PartialEq, Debug)]
+ struct Opt<T>
+ where
+ T: FromStr,
+ <T as FromStr>::Err: fmt::Debug + fmt::Display,
+ {
+ pub answer: T,
}
assert_eq!(
- Opt::<isize>{answer:42},
- Opt::<isize>::from_iter(&[ "--answer", "42" ])
+ Opt::<isize> { answer: 42 },
+ Opt::<isize>::from_iter(&["--answer", "42"])
)
}
diff --git a/tests/issues.rs b/tests/issues.rs
index 8b4ac4b..5860c49 100644
--- a/tests/issues.rs
+++ b/tests/issues.rs
@@ -115,3 +115,32 @@ fn issue_359() {
Opt::from_iter(&["test", "only_one_arg"])
);
}
+
+#[test]
+fn issue_490() {
+ use std::iter::FromIterator;
+ use std::str::FromStr;
+ use structopt::StructOpt;
+
+ struct U16ish;
+ impl FromStr for U16ish {
+ type Err = ();
+ fn from_str(_: &str) -> Result<Self, Self::Err> {
+ unimplemented!()
+ }
+ }
+ impl<'a> FromIterator<&'a U16ish> for Vec<u16> {
+ fn from_iter<T: IntoIterator<Item = &'a U16ish>>(_: T) -> Self {
+ unimplemented!()
+ }
+ }
+
+ #[derive(StructOpt, Debug)]
+ struct Opt {
+ opt_vec: Vec<u16>,
+ #[structopt(long)]
+ opt_opt_vec: Option<Vec<u16>>,
+ }
+
+ // Assert that it compiles
+}
diff --git a/tests/macro-errors.rs b/tests/macro-errors.rs
index 54b405a..74342f7 100644
--- a/tests/macro-errors.rs
+++ b/tests/macro-errors.rs
@@ -5,7 +5,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
-#[rustversion::attr(any(not(stable), before(1.43)), ignore)]
+#[rustversion::attr(any(not(stable), before(1.54)), ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
diff --git a/tests/non_literal_attributes.rs b/tests/non_literal_attributes.rs
index 75b6b71..4c3a442 100644
--- a/tests/non_literal_attributes.rs
+++ b/tests/non_literal_attributes.rs
@@ -143,5 +143,9 @@ fn test_parse_hex_function_path() {
let err = HexOpt::clap()
.get_matches_from_safe(&["test", "-n", "gg"])
.unwrap_err();
- assert!(err.message.contains("invalid digit found in string"), err);
+ assert!(
+ err.message.contains("invalid digit found in string"),
+ "{}",
+ err
+ );
}
diff --git a/tests/special_types.rs b/tests/special_types.rs
index ffed5e2..ac7d143 100644
--- a/tests/special_types.rs
+++ b/tests/special_types.rs
@@ -17,7 +17,7 @@ fn special_types_bool() {
Ok(self::bool(s.into()))
}
}
- };
+ }
#[derive(StructOpt, PartialEq, Debug)]
struct Opt {
diff --git a/tests/subcommands.rs b/tests/subcommands.rs
index 1fc8e76..4ee738b 100644
--- a/tests/subcommands.rs
+++ b/tests/subcommands.rs
@@ -301,3 +301,49 @@ fn external_subcommand_optional() {
assert_eq!(Opt::from_iter(&["test"]), Opt { sub: None });
}
+
+#[test]
+fn skip_subcommand() {
+ #[derive(Debug, PartialEq, StructOpt)]
+ struct Opt {
+ #[structopt(subcommand)]
+ sub: Subcommands,
+ }
+
+ #[derive(Debug, PartialEq, StructOpt)]
+ enum Subcommands {
+ Add,
+ Remove,
+
+ #[allow(dead_code)]
+ #[structopt(skip)]
+ Skip,
+ }
+
+ assert_eq!(
+ Opt::from_iter(&["test", "add"]),
+ Opt {
+ sub: Subcommands::Add
+ }
+ );
+
+ assert_eq!(
+ Opt::from_iter(&["test", "remove"]),
+ Opt {
+ sub: Subcommands::Remove
+ }
+ );
+
+ let res = Opt::from_iter_safe(&["test", "skip"]);
+ assert!(
+ matches!(
+ res,
+ Err(clap::Error {
+ kind: clap::ErrorKind::UnknownArgument,
+ ..
+ })
+ ),
+ "Unexpected result: {:?}",
+ res
+ );
+}
diff --git a/tests/ui/non_existent_attr.stderr b/tests/ui/non_existent_attr.stderr
index 61f784e..5765597 100644
--- a/tests/ui/non_existent_attr.stderr
+++ b/tests/ui/non_existent_attr.stderr
@@ -1,4 +1,4 @@
-error[E0599]: no method named `non_existing_attribute` found for struct `Arg<'_, '_>` in the current scope
+error[E0599]: no method named `non_existing_attribute` found for struct `Arg` in the current scope
--> $DIR/non_existent_attr.rs:14:24
|
14 | #[structopt(short, non_existing_attribute = 1)]
diff --git a/tests/ui/tuple_struct.stderr b/tests/ui/tuple_struct.stderr
index 31705c9..ad92385 100644
--- a/tests/ui/tuple_struct.stderr
+++ b/tests/ui/tuple_struct.stderr
@@ -4,4 +4,4 @@ error: structopt only supports non-tuple structs and enums
11 | #[derive(StructOpt, Debug)]
| ^^^^^^^^^
|
- = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the derive macro `StructOpt` (in Nightly builds, run with -Z macro-backtrace for more info)