Skip to content

Commit

Permalink
Auto merge of #5446 - csmoe:new_name, r=alexcrichton
Browse files Browse the repository at this point in the history
Emit correct project name with --name

Fixes #5440
  • Loading branch information
bors committed May 2, 2018
2 parents 9d57564 + 1edfd9b commit 2eebc86
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bin/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ pub fn cli() -> App {

pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let opts = args.new_options(config)?;

ops::new(&opts, config)?;
let path = args.value_of("path").unwrap();
let project_name = if let Some(name) = args.value_of("name") {
name
} else {
path
};
config
.shell()
.status("Created", format!("{} `{}` project", opts.kind, path))?;
.status("Created", format!("{} `{}` project", opts.kind, project_name))?;
Ok(())
}
15 changes: 15 additions & 0 deletions tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,18 @@ fn explicit_invalid_name_not_suggested() {
),
);
}

#[test]
fn explicit_project_name() {
assert_that(
cargo_process("new")
.arg("--lib")
.arg("foo")
.arg("--name")
.arg("bar")
.env("USER", "foo"),
execs()
.with_status(0)
.with_stderr("[CREATED] library `bar` project"),
);
}

0 comments on commit 2eebc86

Please sign in to comment.