Skip to content

Commit d4e4b7f

Browse files
committed
refactor(common)!: remove verbose flag in several places
1 parent c94ef35 commit d4e4b7f

File tree

6 files changed

+12
-24
lines changed

6 files changed

+12
-24
lines changed

src/cli/common.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,13 @@ pub(crate) fn read_line(process: &Process) -> Result<String> {
127127
pub(super) struct Notifier {
128128
tracker: Mutex<DownloadTracker>,
129129
ram_notice_shown: RefCell<bool>,
130-
verbose: bool,
131130
}
132131

133132
impl Notifier {
134-
pub(super) fn new(verbose: bool, quiet: bool, process: &Process) -> Self {
133+
pub(super) fn new(quiet: bool, process: &Process) -> Self {
135134
Self {
136135
tracker: Mutex::new(DownloadTracker::new_with_display_progress(!quiet, process)),
137136
ram_notice_shown: RefCell::new(false),
138-
verbose,
139137
}
140138
}
141139

@@ -158,9 +156,7 @@ impl Notifier {
158156
for n in format!("{n}").lines() {
159157
match level {
160158
NotificationLevel::Debug => {
161-
if self.verbose {
162-
debug!("{}", n);
163-
}
159+
debug!("{}", n);
164160
}
165161
NotificationLevel::Info => {
166162
info!("{}", n);
@@ -180,13 +176,8 @@ impl Notifier {
180176
}
181177

182178
#[tracing::instrument(level = "trace")]
183-
pub(crate) fn set_globals(
184-
current_dir: PathBuf,
185-
verbose: bool,
186-
quiet: bool,
187-
process: &Process,
188-
) -> Result<Cfg<'_>> {
189-
let notifier = Notifier::new(verbose, quiet, process);
179+
pub(crate) fn set_globals(current_dir: PathBuf, quiet: bool, process: &Process) -> Result<Cfg<'_>> {
180+
let notifier = Notifier::new(quiet, process);
190181
Cfg::from_env(current_dir, Arc::new(move |n| notifier.handle(n)), process)
191182
}
192183

src/cli/log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ where
6969
(logger.compact().with_filter(env_filter).boxed(), handle)
7070
} else {
7171
// Receive log lines from Rustup only.
72-
let (env_filter, handle) = reload::Layer::new(EnvFilter::new("rustup=DEBUG"));
72+
let (env_filter, handle) = reload::Layer::new(EnvFilter::new("rustup=INFO"));
7373
(
7474
logger
7575
.event_format(EventFormatter)

src/cli/proxy_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub async fn main(arg0: &str, current_dir: PathBuf, process: &Process) -> Result
3131
.skip(1 + toolchain.is_some() as usize)
3232
.collect();
3333

34-
let cfg = set_globals(current_dir, false, true, process)?;
34+
let cfg = set_globals(current_dir, true, process)?;
3535
let cmd = cfg.resolve_local_toolchain(toolchain)?.command(arg0)?;
3636
run_command_for_dir(cmd, arg0, &cmd_args)
3737
}

src/cli/rustup_mode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result<utils::Exit
545545
Err(err) if err.kind() == DisplayVersion => {
546546
write!(process.stdout().lock(), "{err}")?;
547547
info!("This is the version for the rustup toolchain manager, not the rustc compiler.");
548-
let mut cfg = common::set_globals(current_dir, false, true, process)?;
548+
let mut cfg = common::set_globals(current_dir, true, process)?;
549549
match cfg.active_rustc_version() {
550550
Ok(Some(version)) => info!("The currently active `rustc` version is `{version}`"),
551551
Ok(None) => info!("No `rustc` is currently active"),
@@ -570,7 +570,7 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result<utils::Exit
570570
}
571571
};
572572

573-
let cfg = &mut common::set_globals(current_dir, matches.verbose, matches.quiet, process)?;
573+
let cfg = &mut common::set_globals(current_dir, matches.quiet, process)?;
574574

575575
if let Some(t) = &matches.plus_toolchain {
576576
cfg.set_toolchain_override(t);

src/cli/self_update.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ fn canonical_cargo_home(process: &Process) -> Result<Cow<'static, str>> {
491491
pub(crate) async fn install(
492492
current_dir: PathBuf,
493493
no_prompt: bool,
494-
verbose: bool,
495494
quiet: bool,
496495
mut opts: InstallOpts<'_>,
497496
process: &Process,
@@ -549,7 +548,7 @@ pub(crate) async fn install(
549548
}
550549

551550
let no_modify_path = opts.no_modify_path;
552-
if let Err(e) = maybe_install_rust(current_dir, verbose, quiet, opts, process).await {
551+
if let Err(e) = maybe_install_rust(current_dir, quiet, opts, process).await {
553552
report_error(&e, process);
554553

555554
// On windows, where installation happens in a console
@@ -804,7 +803,6 @@ pub(crate) fn install_proxies(process: &Process) -> Result<()> {
804803

805804
async fn maybe_install_rust(
806805
current_dir: PathBuf,
807-
verbose: bool,
808806
quiet: bool,
809807
opts: InstallOpts<'_>,
810808
process: &Process,
@@ -828,7 +826,7 @@ async fn maybe_install_rust(
828826
fs::create_dir_all(home).context("unable to create ~/.rustup")?;
829827
}
830828

831-
let mut cfg = common::set_globals(current_dir, verbose, quiet, process)?;
829+
let mut cfg = common::set_globals(current_dir, quiet, process)?;
832830

833831
let (components, targets) = (opts.components, opts.targets);
834832
let toolchain = opts.install(&mut cfg)?;
@@ -1230,8 +1228,7 @@ mod tests {
12301228
home.apply(&mut vars);
12311229
let tp = TestProcess::with_vars(vars);
12321230
let mut cfg =
1233-
common::set_globals(tp.process.current_dir().unwrap(), false, false, &tp.process)
1234-
.unwrap();
1231+
common::set_globals(tp.process.current_dir().unwrap(), false, &tp.process).unwrap();
12351232

12361233
let opts = InstallOpts {
12371234
default_host_triple: None,

src/cli/setup_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,5 @@ pub async fn main(
131131
targets: &target.iter().map(|s| &**s).collect::<Vec<_>>(),
132132
};
133133

134-
self_update::install(current_dir, no_prompt, verbose, quiet, opts, process).await
134+
self_update::install(current_dir, no_prompt, quiet, opts, process).await
135135
}

0 commit comments

Comments
 (0)