Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backwards-compatibility for old cargo-tree flags. #8115

Merged
merged 1 commit into from
Apr 15, 2020
Merged
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
27 changes: 21 additions & 6 deletions src/bin/cargo/commands/tree.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::cli;
use crate::command_prelude::*;
use anyhow::{bail, format_err};
use cargo::core::dependency::DepKind;
Expand Down Expand Up @@ -88,9 +89,22 @@ pub fn cli() -> App {
.short("f")
.default_value("{p}"),
)
.arg(
// Backwards compatibility with old cargo-tree.
Arg::with_name("version")
.long("version")
.short("V")
.hidden(true),
)
}

pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
if args.is_present("version") {
let verbose = args.occurrences_of("verbose") > 0;
let version = cli::get_version_string(verbose);
print!("{}", version);
return Ok(());
}
let prefix = if args.is_present("no-indent") {
config
.shell()
Expand All @@ -106,12 +120,13 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
};
let prefix = tree::Prefix::from_str(prefix).map_err(|e| anyhow::anyhow!("{}", e))?;

let no_dedupe = args.is_present("no-dedupe") || args.is_present("all");
if args.is_present("all") {
return Err(format_err!(
"The `cargo tree` --all flag has been changed to --no-dedupe.\n\
If you are looking to display all workspace members, use the --workspace flag."
)
.into());
config.shell().warn(
"The `cargo tree` --all flag has been changed to --no-dedupe, \
and may be removed in a future version.\n\
If you are looking to display all workspace members, use the --workspace flag.",
)?;
}

let target = if args.is_present("all-targets") {
Expand Down Expand Up @@ -170,7 +185,7 @@ subtree of the package given to -p.\n\
edge_kinds,
invert,
prefix,
no_dedupe: args.is_present("no-dedupe"),
no_dedupe,
duplicates: args.is_present("duplicates"),
charset,
format: args.value_of("format").unwrap().to_string(),
Expand Down