@@ -34,6 +34,10 @@ pub fn main() -> Result<()> {
34
34
let quiet = matches. is_present ( "quiet" ) ;
35
35
let cfg = & common:: set_globals ( verbose, quiet) ?;
36
36
37
+ if matches. is_present ( "+toolchain" ) {
38
+ override_by_toolchain ( cfg, & matches) ?;
39
+ }
40
+
37
41
if maybe_upgrade_data ( cfg, & matches) ? {
38
42
return Ok ( ( ) ) ;
39
43
}
@@ -130,10 +134,8 @@ pub fn cli() -> App<'static, 'static> {
130
134
. long ( "quiet" ) ,
131
135
)
132
136
. arg (
133
- Arg :: with_name ( "toolchain" )
134
- . help ( TOOLCHAIN_ARG_HELP )
135
- . long ( "toolchain" )
136
- . takes_value ( true ) ,
137
+ Arg :: with_name ( "+toolchain" )
138
+ . help ( "release channel (e.g. +stable) or custom toolchain to set override" ) ,
137
139
)
138
140
. subcommand (
139
141
SubCommand :: with_name ( "dump-testament" )
@@ -819,8 +821,7 @@ fn run(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
819
821
820
822
fn which ( cfg : & Cfg , m : & ArgMatches < ' _ > ) -> Result < ( ) > {
821
823
let binary = m. value_of ( "command" ) . expect ( "" ) ;
822
- let toolchain_provided = m. is_present ( "toolchain" ) ;
823
- let binary_path = if toolchain_provided {
824
+ let binary_path = if m. is_present ( "toolchain" ) {
824
825
let toolchain = m. value_of ( "toolchain" ) . expect ( "" ) ;
825
826
cfg. which_binary_by_toolchain ( toolchain, binary) ?
826
827
. expect ( "binary not found" )
@@ -1148,6 +1149,29 @@ fn toolchain_remove(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1148
1149
Ok ( ( ) )
1149
1150
}
1150
1151
1152
+ fn override_by_toolchain ( cfg : & Cfg , m : & ArgMatches < ' _ > ) -> Result < ( ) > {
1153
+ let toolchain = m. value_of ( "+toolchain" ) . expect ( "" ) ;
1154
+ let toolchain = cfg. get_toolchain ( & toolchain[ 1 ..] , false ) ?;
1155
+
1156
+ let status = if !toolchain. is_custom ( ) {
1157
+ Some ( toolchain. install_from_dist_if_not_installed ( ) ?)
1158
+ } else if !toolchain. exists ( ) {
1159
+ return Err ( ErrorKind :: ToolchainNotInstalled ( toolchain. name ( ) . to_string ( ) ) . into ( ) ) ;
1160
+ } else {
1161
+ None
1162
+ } ;
1163
+
1164
+ let path = utils:: current_dir ( ) ?;
1165
+ toolchain. make_override ( & path) ?;
1166
+
1167
+ if let Some ( status) = status {
1168
+ println ! ( ) ;
1169
+ common:: show_channel_update ( cfg, toolchain. name ( ) , Ok ( status) ) ?;
1170
+ }
1171
+
1172
+ Ok ( ( ) )
1173
+ }
1174
+
1151
1175
fn override_add ( cfg : & Cfg , m : & ArgMatches < ' _ > ) -> Result < ( ) > {
1152
1176
let toolchain = m. value_of ( "toolchain" ) . expect ( "" ) ;
1153
1177
let toolchain = cfg. get_toolchain ( toolchain, false ) ?;
0 commit comments