Skip to content

Commit 207f418

Browse files
committed
feat: Add hint for adding members to workspace
1 parent bb9b25f commit 207f418

File tree

7 files changed

+22
-0
lines changed

7 files changed

+22
-0
lines changed

src/cargo/ops/cargo_new.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
845845

846846
// Try to add the new package to the workspace members.
847847
update_manifest_with_new_member(
848+
config,
848849
&root_manifest_path,
849850
&mut workspace_document,
850851
&display_path,
@@ -962,6 +963,7 @@ fn update_manifest_with_inherited_workspace_package_keys(
962963
/// - If [workspace.members] doesn't exist in the manifest, it will add a new section
963964
/// with the new package in it.
964965
fn update_manifest_with_new_member(
966+
config: &Config,
965967
root_manifest_path: &Path,
966968
workspace_document: &mut toml_edit::Document,
967969
display_path: &str,
@@ -992,11 +994,25 @@ fn update_manifest_with_new_member(
992994
if was_sorted {
993995
members.sort_by(|lhs, rhs| lhs.as_str().cmp(&rhs.as_str()));
994996
}
997+
config.shell().status(
998+
"Adding",
999+
format!(
1000+
"`{display_path}` as member of workspace at `{}`",
1001+
root_manifest_path.parent().unwrap().display()
1002+
),
1003+
)?
9951004
} else {
9961005
let mut array = Array::new();
9971006
array.push(display_path);
9981007

9991008
workspace["members"] = toml_edit::value(array);
1009+
config.shell().status(
1010+
"Adding",
1011+
format!(
1012+
"`{display_path}` as member of workspace at `{}`",
1013+
root_manifest_path.parent().unwrap().display()
1014+
),
1015+
)?
10001016
}
10011017
}
10021018

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Creating binary (application) package
2+
Adding `crates/foo` as member of workspace at `[ROOT]/case`
23
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Creating binary (application) `foo` package
2+
Adding `crates/foo` as member of workspace at `[ROOT]/case`
23
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Creating binary (application) `foo` package
2+
Adding `crates/foo` as member of workspace at `[ROOT]/case`
23
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Creating binary (application) `foo` package
2+
Adding `crates/foo` as member of workspace at `[ROOT]/case`
23
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Creating binary (application) `foo` package
2+
Adding `crates/foo` as member of workspace at `[ROOT]/case`
23
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Creating library `bar` package
2+
Adding `bar` as member of workspace at `[ROOT]/case`
23
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

0 commit comments

Comments
 (0)