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

Print all features when the verbose flag is set #15375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/bin/cargo/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
section,
dry_run,
honor_rust_version,
verbose: args.verbose() != 0, // just one verbosity level for add.
};
add(&ws, &options)?;

Expand Down
12 changes: 8 additions & 4 deletions src/cargo/ops/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::core::Package;
use crate::core::Registry;
use crate::core::Shell;
use crate::core::Summary;
use crate::core::Verbosity;
use crate::core::Workspace;
use crate::sources::source::QueryKind;
use crate::util::cache_lock::CacheLockMode;
Expand Down Expand Up @@ -60,6 +61,7 @@ pub struct AddOptions<'a> {
pub dry_run: bool,
/// Whether the minimum supported Rust version should be considered during resolution
pub honor_rust_version: Option<bool>,
pub verbose: bool,
}

/// Add dependencies to a manifest
Expand Down Expand Up @@ -168,7 +170,7 @@ pub fn add(workspace: &Workspace<'_>, options: &AddOptions<'_>) -> CargoResult<(
write!(message, "no features available for crate {}", dep.name)?;
} else {
if !deactivated.is_empty() {
if deactivated.len() <= MAX_FEATURE_PRINTS {
if options.verbose || deactivated.len() <= MAX_FEATURE_PRINTS {
writeln!(
message,
"disabled features:\n {}",
Expand All @@ -188,7 +190,8 @@ pub fn add(workspace: &Workspace<'_>, options: &AddOptions<'_>) -> CargoResult<(
}
}
if !activated.is_empty() {
if deactivated.len() + activated.len() <= MAX_FEATURE_PRINTS {
if options.verbose || deactivated.len() + activated.len() <= MAX_FEATURE_PRINTS
{
writeln!(
message,
"enabled features:\n {}",
Expand Down Expand Up @@ -1113,6 +1116,7 @@ fn print_dep_table_msg(shell: &mut Shell, dep: &DependencyUI) -> CargoResult<()>
return Ok(());
}

let verbose = shell.verbosity() == Verbosity::Verbose;
let stderr = shell.err();
let good = style::GOOD;
let error = style::ERROR;
Expand All @@ -1127,15 +1131,15 @@ fn print_dep_table_msg(shell: &mut Shell, dep: &DependencyUI) -> CargoResult<()>
let total_activated = activated.len();
let total_deactivated = deactivated.len();

if total_activated <= MAX_FEATURE_PRINTS {
if verbose || total_activated <= MAX_FEATURE_PRINTS {
for feat in activated {
writeln!(stderr, "{prefix}{good}+{good:#} {feat}")?;
}
} else {
writeln!(stderr, "{prefix}{total_activated} activated features")?;
}

if total_activated + total_deactivated <= MAX_FEATURE_PRINTS {
if verbose || total_activated + total_deactivated <= MAX_FEATURE_PRINTS {
for feat in deactivated {
writeln!(stderr, "{prefix}{error}-{error:#} {feat}")?;
}
Expand Down