Skip to content

Commit b9f150c

Browse files
committed
Rename customize_install() to InstallOpts::customize()
1 parent 370cd17 commit b9f150c

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

src/cli/self_update.rs

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,49 @@ pub(crate) struct InstallOpts<'a> {
9595
pub targets: &'a [&'a str],
9696
}
9797

98+
impl<'a> InstallOpts<'a> {
99+
// Interactive editing of the install options
100+
fn customize(&mut self) -> Result<()> {
101+
writeln!(
102+
process().stdout().lock(),
103+
"I'm going to ask you the value of each of these installation options.\n\
104+
You may simply press the Enter key to leave unchanged."
105+
)?;
106+
107+
writeln!(process().stdout().lock())?;
108+
109+
self.default_host_triple = Some(common::question_str(
110+
"Default host triple?",
111+
&self
112+
.default_host_triple
113+
.take()
114+
.unwrap_or_else(|| TargetTriple::from_host_or_build().to_string()),
115+
)?);
116+
117+
self.default_toolchain = Some(MaybeOfficialToolchainName::try_from(common::question_str(
118+
"Default toolchain? (stable/beta/nightly/none)",
119+
&self
120+
.default_toolchain
121+
.as_ref()
122+
.map(ToString::to_string)
123+
.unwrap_or("stable".into()),
124+
)?)?);
125+
126+
self.profile = common::question_str(
127+
&format!(
128+
"Profile (which tools and data to install)? ({})",
129+
Profile::names().join("/")
130+
),
131+
&self.profile,
132+
)?;
133+
134+
self.no_modify_path =
135+
!common::question_bool("Modify PATH variable?", !self.no_modify_path)?;
136+
137+
Ok(())
138+
}
139+
}
140+
98141
#[cfg(feature = "no-self-update")]
99142
pub(crate) const NEVER_SELF_UPDATE: bool = true;
100143
#[cfg(not(feature = "no-self-update"))]
@@ -456,7 +499,7 @@ pub(crate) async fn install(
456499
}
457500
Confirm::Advanced => {
458501
customized_install = true;
459-
opts = customize_install(opts)?;
502+
opts.customize()?;
460503
}
461504
}
462505
}
@@ -710,45 +753,6 @@ fn current_install_opts(opts: &InstallOpts<'_>) -> String {
710753
)
711754
}
712755

713-
// Interactive editing of the install options
714-
fn customize_install(mut opts: InstallOpts<'_>) -> Result<InstallOpts<'_>> {
715-
writeln!(
716-
process().stdout().lock(),
717-
"I'm going to ask you the value of each of these installation options.\n\
718-
You may simply press the Enter key to leave unchanged."
719-
)?;
720-
721-
writeln!(process().stdout().lock())?;
722-
723-
opts.default_host_triple = Some(common::question_str(
724-
"Default host triple?",
725-
&opts
726-
.default_host_triple
727-
.unwrap_or_else(|| TargetTriple::from_host_or_build().to_string()),
728-
)?);
729-
730-
opts.default_toolchain = Some(MaybeOfficialToolchainName::try_from(common::question_str(
731-
"Default toolchain? (stable/beta/nightly/none)",
732-
&opts
733-
.default_toolchain
734-
.as_ref()
735-
.map(ToString::to_string)
736-
.unwrap_or("stable".into()),
737-
)?)?);
738-
739-
opts.profile = common::question_str(
740-
&format!(
741-
"Profile (which tools and data to install)? ({})",
742-
Profile::names().join("/")
743-
),
744-
&opts.profile,
745-
)?;
746-
747-
opts.no_modify_path = !common::question_bool("Modify PATH variable?", !opts.no_modify_path)?;
748-
749-
Ok(opts)
750-
}
751-
752756
fn install_bins() -> Result<()> {
753757
let bin_path = utils::cargo_home()?.join("bin");
754758
let this_exe_path = utils::current_exe()?;

0 commit comments

Comments
 (0)