@@ -95,6 +95,49 @@ pub(crate) struct InstallOpts<'a> {
95
95
pub targets : & ' a [ & ' a str ] ,
96
96
}
97
97
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
+
98
141
#[ cfg( feature = "no-self-update" ) ]
99
142
pub ( crate ) const NEVER_SELF_UPDATE : bool = true ;
100
143
#[ cfg( not( feature = "no-self-update" ) ) ]
@@ -456,7 +499,7 @@ pub(crate) async fn install(
456
499
}
457
500
Confirm :: Advanced => {
458
501
customized_install = true ;
459
- opts = customize_install ( opts ) ?;
502
+ opts. customize ( ) ?;
460
503
}
461
504
}
462
505
}
@@ -710,45 +753,6 @@ fn current_install_opts(opts: &InstallOpts<'_>) -> String {
710
753
)
711
754
}
712
755
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
-
752
756
fn install_bins ( ) -> Result < ( ) > {
753
757
let bin_path = utils:: cargo_home ( ) ?. join ( "bin" ) ;
754
758
let this_exe_path = utils:: current_exe ( ) ?;
0 commit comments