Skip to content

Commit e8f68cc

Browse files
committed
Auto merge of #1317 - alexcrichton:issue-1297, r=huonw
Not sure why we were doing this, it's quite useful! Closes #1297
2 parents e7393a0 + 02e7dc8 commit e8f68cc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/cargo/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,7 @@ fn flags_from_args<'a, T>(usage: &str, args: &[String],
210210
.version(Some(version()));
211211
docopt.decode().map_err(|e| {
212212
let code = if e.fatal() {1} else {0};
213-
let desc = match e {
214-
docopt::Error::WithProgramUsage(_, s) => s,
215-
ref e if e.fatal() => e.description().to_string(),
216-
e => e.to_string(),
217-
};
218-
CliError::from_error(human(desc), code)
213+
CliError::from_error(human(e.to_string()), code)
219214
})
220215
}
221216

tests/test_cargo_new.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ test!(no_argument {
7272
assert_that(cargo_process("new"),
7373
execs().with_status(1)
7474
.with_stderr("\
75+
Invalid arguments.
76+
7577
Usage:
7678
cargo new [options] <path>
7779
cargo new -h | --help
@@ -189,3 +191,15 @@ test!(subpackage_no_git {
189191
assert_that(&paths::root().join("foo/components/subcomponent/.gitignore"),
190192
is_not(existing_file()));
191193
});
194+
195+
test!(unknown_flags {
196+
assert_that(cargo_process("new").arg("foo").arg("--flag"),
197+
execs().with_status(1)
198+
.with_stderr("\
199+
Unknown flag: '--flag'
200+
201+
Usage:
202+
cargo new [..]
203+
cargo new [..]
204+
"));
205+
});

0 commit comments

Comments
 (0)