Skip to content

Commit 79766cf

Browse files
rami3lChrisDenton
authored andcommitted
refactor(cli/self-update): move current_install_opts() to InstallOpts::display()
1 parent 61e7a84 commit 79766cf

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

src/cli/self_update.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl InstallOpts<'_> {
159159
md(&mut term, msg);
160160
let mut customized_install = false;
161161
loop {
162-
md(&mut term, current_install_opts(&self, process));
162+
md(&mut term, self.display(process));
163163
match common::confirm_advanced(customized_install, process)? {
164164
Confirm::No => {
165165
info!("aborting installation");
@@ -438,6 +438,28 @@ impl InstallOpts<'_> {
438438
trace!("Successfully resolved installation toolchain as: {resolved}");
439439
Ok(())
440440
}
441+
442+
fn display(&self, process: &Process) -> String {
443+
format!(
444+
r"Current installation options:
445+
446+
- ` `default host tuple: `{}`
447+
- ` `default toolchain: `{}`
448+
- ` `profile: `{}`
449+
- modify PATH variable: `{}`
450+
",
451+
self.default_host_tuple.as_ref().map_or_else(
452+
|| TargetTuple::from_host_or_build(process),
453+
TargetTuple::new,
454+
),
455+
match &self.default_toolchain {
456+
Some(name) => name.to_string(),
457+
None => "stable (default)".to_owned(),
458+
},
459+
self.profile,
460+
if !self.no_modify_path { "yes" } else { "no" }
461+
)
462+
}
441463
}
442464

443465
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
@@ -701,28 +723,6 @@ fn pre_install_msg(no_modify_path: bool, process: &Process) -> Result<String> {
701723
}
702724
}
703725

704-
fn current_install_opts(opts: &InstallOpts<'_>, process: &Process) -> String {
705-
format!(
706-
r"Current installation options:
707-
708-
- ` `default host tuple: `{}`
709-
- ` `default toolchain: `{}`
710-
- ` `profile: `{}`
711-
- modify PATH variable: `{}`
712-
",
713-
opts.default_host_tuple
714-
.as_ref()
715-
.map(TargetTuple::new)
716-
.unwrap_or_else(|| TargetTuple::from_host_or_build(process)),
717-
match &opts.default_toolchain {
718-
Some(name) => name.to_string(),
719-
None => "stable (default)".to_owned(),
720-
},
721-
opts.profile,
722-
if !opts.no_modify_path { "yes" } else { "no" }
723-
)
724-
}
725-
726726
#[cfg(unix)]
727727
fn warn_if_default_linker_missing(process: &Process) {
728728
// Search for linker in PATH

0 commit comments

Comments
 (0)