Skip to content

Commit 2eebc86

Browse files
committed
Auto merge of #5446 - csmoe:new_name, r=alexcrichton
Emit correct project name with --name Fixes #5440
2 parents 9d57564 + 1edfd9b commit 2eebc86

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/bin/commands/new.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ pub fn cli() -> App {
1111

1212
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
1313
let opts = args.new_options(config)?;
14+
1415
ops::new(&opts, config)?;
1516
let path = args.value_of("path").unwrap();
17+
let project_name = if let Some(name) = args.value_of("name") {
18+
name
19+
} else {
20+
path
21+
};
1622
config
1723
.shell()
18-
.status("Created", format!("{} `{}` project", opts.kind, path))?;
24+
.status("Created", format!("{} `{}` project", opts.kind, project_name))?;
1925
Ok(())
2026
}

tests/testsuite/new.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,18 @@ fn explicit_invalid_name_not_suggested() {
545545
),
546546
);
547547
}
548+
549+
#[test]
550+
fn explicit_project_name() {
551+
assert_that(
552+
cargo_process("new")
553+
.arg("--lib")
554+
.arg("foo")
555+
.arg("--name")
556+
.arg("bar")
557+
.env("USER", "foo"),
558+
execs()
559+
.with_status(0)
560+
.with_stderr("[CREATED] library `bar` project"),
561+
);
562+
}

0 commit comments

Comments
 (0)