Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/bin/cargo/commands/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,18 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
}
_ => {
return Err(format_err!(
"The `-i` flag requires a package name.\n\
\n\
The `-i` flag is used to inspect the reverse dependencies of a specific\n\
package. It will invert the tree and display the packages that depend on the\n\
given package.\n\
\n\
Note that in a workspace, by default it will only display the package's\n\
reverse dependencies inside the tree of the workspace member in the current\n\
directory. The --workspace flag can be used to extend it so that it will show\n\
the package's reverse dependencies across the entire workspace. The -p flag\n\
can be used to display the package's reverse dependencies only with the\n\
subtree of the package given to -p.\n\
"
r#"a package name is required for `-i` but none was supplied

note: `-p <spec> -i` is not supported; pass the package name to `-i` directly.

help: to inspect the reverse dependencies of a specific package, pass the name directly to `-i`:

cargo tree -i <spec>

help: if you are in a workspace and want to search across all members, use:

cargo tree --workspace -i <spec>
"#
)
.into());
}
Expand Down
54 changes: 54 additions & 0 deletions tests/testsuite/cargo_tree/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,60 @@ c v1.0.0
│ └── foo v0.1.0 ([ROOT]/foo)
└── foo v0.1.0 ([ROOT]/foo)

"#]])
.run();
}

#[cargo_test]
fn invert_without_package_name() {
let p = project()
.file("Cargo.toml", &basic_manifest("foo", "0.1.0"))
.file("src/lib.rs", "")
.build();

p.cargo("tree -i")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] a package name is required for `-i` but none was supplied

[NOTE] `-p <spec> -i` is not supported; pass the package name to `-i` directly.

[HELP] to inspect the reverse dependencies of a specific package, pass the name directly to `-i`:

cargo tree -i <spec>

[HELP] if you are in a workspace and want to search across all members, use:

cargo tree --workspace -i <spec>


"#]])
.run();
}

#[cargo_test]
fn invert_without_package_name_workspace() {
let p = project()
.file("Cargo.toml", &basic_manifest("foo", "0.1.0"))
.file("src/lib.rs", "")
.build();

p.cargo("tree --workspace -i")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] a package name is required for `-i` but none was supplied

[NOTE] `-p <spec> -i` is not supported; pass the package name to `-i` directly.

[HELP] to inspect the reverse dependencies of a specific package, pass the name directly to `-i`:

cargo tree -i <spec>

[HELP] if you are in a workspace and want to search across all members, use:

cargo tree --workspace -i <spec>


"#]])
.run();
}
Expand Down