Skip to content

Commit 5fa5b2a

Browse files
committed
Convert cargo tree warning
1 parent 36bf7f6 commit 5fa5b2a

File tree

2 files changed

+14
-6
lines changed
  • src/bin/cargo/commands
  • tests/testsuite/cargo_tree/dupe

2 files changed

+14
-6
lines changed

src/bin/cargo/commands/tree.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::cli;
22
use crate::command_prelude::*;
3+
use annotate_snippets::Level;
34
use anyhow::{bail, format_err};
45
use cargo::core::dependency::DepKind;
56
use cargo::ops::Packages;
@@ -141,10 +142,16 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
141142

142143
let no_dedupe = args.flag("no-dedupe") || args.flag("all");
143144
if args.flag("all") {
144-
gctx.shell().warn(
145-
"The `cargo tree` --all flag has been changed to --no-dedupe, \
146-
and may be removed in a future version.\n\
147-
If you are looking to display all workspace members, use the --workspace flag.",
145+
gctx.shell().print_report(
146+
&[Level::WARNING
147+
.secondary_title(
148+
"the `cargo tree` --all flag has been changed to --no-dedupe, \
149+
and may be removed in a future version)",
150+
)
151+
.element(Level::HELP.message(
152+
"if you are looking to display all workspace members, use the --workspace flag",
153+
))],
154+
false,
148155
)?;
149156
}
150157

tests/testsuite/cargo_tree/dupe/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ fn all_flag() {
6060
.build();
6161

6262
p.cargo("tree --all").with_stderr_data(str![[r#"
63-
[WARNING] The `cargo tree` --all flag has been changed to --no-dedupe, and may be removed in a future version.
64-
If you are looking to display all workspace members, use the --workspace flag.
63+
[WARNING] the `cargo tree` --all flag has been changed to --no-dedupe, and may be removed in a future version)
64+
|
65+
= [HELP] if you are looking to display all workspace members, use the --workspace flag
6566
...
6667
"#]]).run();
6768
}

0 commit comments

Comments
 (0)