Skip to content

Commit

Permalink
fix(add): Ensure users know a feature is being created
Browse files Browse the repository at this point in the history
  • Loading branch information
epage authored and stupendoussuperpowers committed Feb 28, 2024
1 parent 6d0c558 commit 04f9ed0
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ pub fn add(workspace: &Workspace<'_>, options: &AddOptions<'_>) -> CargoResult<(
let new_feature: toml_edit::Value =
[format!("dep:{dep_name}")].iter().collect();
table[dep_key] = toml_edit::value(new_feature);
options
.config
.shell()
.status("Adding", format!("feature `{dep_key}`"))?;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/change_rename_target/stderr.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Updating `dummy-registry` index
Adding my-package2 v99999.0.0 to optional dependencies.
Adding feature `some-package`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Adding foo (workspace) to optional dependencies.
Adding feature `foo`
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/optional/stderr.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Updating `dummy-registry` index
Adding my-package v0.1.0 to optional dependencies.
Adding feature `my-package`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Adding cargo-list-test-fixture-dependency (local) to optional dependencies.
Adding feature `cargo-list-test-fixture-dependency`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Adding foo (workspace) to optional dependencies.
Adding feature `foo`
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/overwrite_name_noop/stderr.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Features:
+ mouth
+ nose
Adding feature `your-face`
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Updating `dummy-registry` index
Adding my-package v0.1.0 to optional dependencies.
Adding feature `my-package`
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/overwrite_optional/stderr.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Updating `dummy-registry` index
Adding my-package v0.1.0 to optional dependencies.
Adding feature `my-package`
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/overwrite_path_noop/stderr.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Features:
+ mouth
+ nose
Adding feature `your-face`
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Updating `dummy-registry` index
Adding cargo-list-test-fixture-dependency v20.0 to optional dependencies.
Adding feature `cargo-list-test-fixture-dependency`
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Updating `dummy-registry` index
Adding versioned-package v0.1.1 to optional dependencies.
Adding feature `a1`
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Updating git repository `[ROOTURL]/versioned-package`
Adding versioned-package (git) to optional dependencies.
Adding feature `versioned-package`
Updating git repository `[ROOTURL]/versioned-package`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Adding cargo-list-test-fixture-dependency (local) to optional dependencies.
Adding feature `cargo-list-test-fixture-dependency`

0 comments on commit 04f9ed0

Please sign in to comment.