Skip to content

Commit 5ccc5e0

Browse files
committed
Change old flags to warnings instead of errors.
Except --all which is ambiguous which flag it means.
1 parent 3b1df3a commit 5ccc5e0

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

src/bin/cargo/commands/tree.rs

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,52 @@ pub fn cli() -> App {
8383
}
8484

8585
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
86-
if args.is_present("no-indent") {
87-
return Err(format_err!("the --no-indent flag has been changed to --prefix=none").into());
88-
}
89-
if args.is_present("prefix-depth") {
90-
return Err(
91-
format_err!("the --prefix-depth flag has been changed to --prefix=depth").into(),
92-
);
93-
}
86+
let prefix = if args.is_present("no-indent") {
87+
config
88+
.shell()
89+
.warn("the --no-indent flag has been changed to --prefix=none")?;
90+
"none"
91+
} else if args.is_present("prefix-depth") {
92+
config
93+
.shell()
94+
.warn("the --prefix-depth flag has been changed to --prefix=depth")?;
95+
"depth"
96+
} else {
97+
args.value_of("prefix").unwrap()
98+
};
99+
let prefix = tree::Prefix::from_str(prefix).map_err(|e| anyhow::anyhow!("{}", e))?;
100+
94101
if args.is_present("all") {
95102
return Err(format_err!(
96103
"The `cargo tree` --all flag has been changed to --no-dedupe.\n\
97104
If you are looking to display all workspace members, use the --workspace flag."
98105
)
99106
.into());
100107
}
101-
if args.is_present("all-targets") {
102-
return Err(format_err!("the --all-targets flag has been changed to --target=all").into());
103-
}
104-
if args.is_present("no-dev-dependencies") {
105-
return Err(format_err!(
106-
"the --no-dev-dependencies flag has changed to --dep-kinds=no-dev"
107-
)
108-
.into());
109-
}
108+
109+
let target = if args.is_present("all-targets") {
110+
config
111+
.shell()
112+
.warn("the --all-targets flag has been changed to --target=all")?;
113+
Some("all")
114+
} else {
115+
args.value_of("target")
116+
};
117+
let target = tree::Target::from_cli(target);
118+
119+
let dep_kinds = if args.is_present("no-dev-dependencies") {
120+
config
121+
.shell()
122+
.warn("the --no-dev-dependencies flag has changed to --dep-kinds=no-dev")?;
123+
Some("no-dev")
124+
} else {
125+
args.value_of("dep-kinds")
126+
};
127+
let dep_kinds = parse_dep_kinds(dep_kinds)?;
128+
110129
let ws = args.workspace(config)?;
111130
let charset = tree::Charset::from_str(args.value_of("charset").unwrap())
112131
.map_err(|e| anyhow::anyhow!("{}", e))?;
113-
let prefix = tree::Prefix::from_str(args.value_of("prefix").unwrap())
114-
.map_err(|e| anyhow::anyhow!("{}", e))?;
115-
let target = tree::Target::from_cli(args.value_of("target"));
116-
let dep_kinds = parse_dep_kinds(args.value_of("dep-kinds"))?;
117132
let opts = tree::TreeOptions {
118133
features: values(args, "features"),
119134
all_features: args.is_present("all-features"),

0 commit comments

Comments
 (0)