diff --git a/src/bin/rustup-init.rs b/src/bin/rustup-init.rs index 591e81297c7..36e98f994c9 100644 --- a/src/bin/rustup-init.rs +++ b/src/bin/rustup-init.rs @@ -93,7 +93,7 @@ async fn run_rustup_inner( utils::current_exe()?; match process.name().as_deref() { - Some("rustup") => rustup_mode::main(current_dir, process).await, + Some("rustup") => rustup_mode::main(current_dir, process, Some(console_filter)).await, Some(n) if n.starts_with("rustup-setup") || n.starts_with("rustup-init") => { // NB: The above check is only for the prefix of the file // name. Browsers rename duplicates to diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 28ed7b29e16..f512e3cb0fd 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -10,6 +10,7 @@ use clap::{builder::PossibleValue, Args, CommandFactory, Parser, Subcommand, Val use clap_complete::Shell; use itertools::Itertools; use tracing::{info, trace, warn}; +use tracing_subscriber::{reload::Handle, EnvFilter, Registry}; use crate::{ cli::{ @@ -68,12 +69,12 @@ fn handle_epipe(res: Result) -> Result { after_help = RUSTUP_HELP, )] struct Rustup { - /// Enable verbose output - #[arg(short, long)] + /// Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset + #[arg(short, long, overrides_with = "quiet")] verbose: bool, - /// Disable progress output - #[arg(short, long, conflicts_with = "verbose")] + /// Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset + #[arg(short, long, overrides_with = "verbose")] quiet: bool, /// Release channel (e.g. +stable) or custom toolchain to set override @@ -532,7 +533,11 @@ enum SetSubcmd { } #[tracing::instrument(level = "trace", fields(args = format!("{:?}", process.args_os().collect::>())))] -pub async fn main(current_dir: PathBuf, process: &Process) -> Result { +pub async fn main( + current_dir: PathBuf, + process: &Process, + console_filter: Option>, +) -> Result { self_update::cleanup_self_updater(process)?; use clap::error::ErrorKind::*; @@ -570,6 +575,21 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result process_res, diff --git a/tests/suite/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml b/tests/suite/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml index c51af98b68a..b2a32685274 100644 --- a/tests/suite/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml +++ b/tests/suite/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml @@ -10,7 +10,7 @@ Usage: rustup-init[EXE] [OPTIONS] Options: -v, --verbose - Enable verbose output + Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset -q, --quiet Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset -y diff --git a/tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml b/tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml index b6771fb5c3e..d83c58a6118 100644 --- a/tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml +++ b/tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml @@ -30,8 +30,10 @@ Arguments: [+toolchain] Release channel (e.g. +stable) or custom toolchain to set override Options: - -v, --verbose Enable verbose output - -q, --quiet Disable progress output + -v, --verbose Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is + unset + -q, --quiet Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is + unset -h, --help Print help -V, --version Print version diff --git a/tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml b/tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml index 4fa43f881ba..95b42763502 100644 --- a/tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml +++ b/tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml @@ -30,8 +30,10 @@ Arguments: [+toolchain] Release channel (e.g. +stable) or custom toolchain to set override Options: - -v, --verbose Enable verbose output - -q, --quiet Disable progress output + -v, --verbose Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is + unset + -q, --quiet Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is + unset -h, --help Print help -V, --version Print version diff --git a/tests/suite/cli-ui/rustup/rustup_only_options_stdout.toml b/tests/suite/cli-ui/rustup/rustup_only_options_stdout.toml index e0d9a66f54c..a2328c4cb37 100644 --- a/tests/suite/cli-ui/rustup/rustup_only_options_stdout.toml +++ b/tests/suite/cli-ui/rustup/rustup_only_options_stdout.toml @@ -32,10 +32,10 @@ Arguments: Options: -v, --verbose - Enable verbose output + Enable verbose output, limit console logger level to 'DEBUG' if 'RUSTUP_LOG' is unset -q, --quiet - Disable progress output + Disable progress output, limit console logger level to 'WARN' if 'RUSTUP_LOG' is unset -h, --help Print help