diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index f9811f7a690..d6a368170f7 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -716,6 +716,22 @@ edition = {} .as_bytes(), )?; + // Create README for binary crates + // Eventually, we will do something similar for library and workspace crates + + if opts.bin { + paths::write( + &path.join("README.md"), + format!( + r#"TODO: add a description of this crate's purpose +cargo install [{}] + "#, + name, + ) + .as_bytes(), + )?; + } + // Create all specified source files (with respective parent directories) if they don't exist. for i in &opts.source_files { diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index 7455094d688..27406660d73 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -25,6 +25,7 @@ fn simple_lib() { assert!(paths::root().join("foo/Cargo.toml").is_file()); assert!(paths::root().join("foo/src/lib.rs").is_file()); assert!(!paths::root().join("foo/.gitignore").is_file()); + assert!(!paths::root().join("foo/README.md").is_file()); let lib = paths::root().join("foo/src/lib.rs"); let mut contents = String::new(); @@ -57,6 +58,7 @@ fn simple_bin() { assert!(paths::root().join("foo").is_dir()); assert!(paths::root().join("foo/Cargo.toml").is_file()); assert!(paths::root().join("foo/src/main.rs").is_file()); + assert!(paths::root().join("foo/README.md").is_file()); cargo_process("build").cwd(&paths::root().join("foo")).run(); assert!(paths::root() @@ -84,6 +86,7 @@ fn simple_git() { assert!(paths::root().join("foo/src/lib.rs").is_file()); assert!(paths::root().join("foo/.git").is_dir()); assert!(paths::root().join("foo/.gitignore").is_file()); + assert!(!paths::root().join("foo/README.md").is_file()); let fp = paths::root().join("foo/.gitignore"); let mut contents = String::new();