@@ -11,7 +11,7 @@ use rustup::{command, Cfg, Toolchain};
11
11
use std:: error:: Error ;
12
12
use std:: io:: { self , Write } ;
13
13
use std:: iter;
14
- use std:: path:: Path ;
14
+ use std:: path:: { Path , PathBuf } ;
15
15
use std:: process:: { self , Command } ;
16
16
17
17
fn handle_epipe ( res : Result < ( ) > ) -> Result < ( ) > {
@@ -348,6 +348,12 @@ pub fn cli() -> App<'static, 'static> {
348
348
Arg :: with_name ( "toolchain" )
349
349
. help ( TOOLCHAIN_ARG_HELP )
350
350
. required ( true ) ,
351
+ )
352
+ . arg (
353
+ Arg :: with_name ( "path" )
354
+ . long ( "path" )
355
+ . takes_value ( true )
356
+ . help ( "Path to the directory" ) ,
351
357
) ,
352
358
)
353
359
. subcommand (
@@ -929,7 +935,12 @@ fn override_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
929
935
None
930
936
} ;
931
937
932
- toolchain. make_override ( & utils:: current_dir ( ) ?) ?;
938
+ let path = if let Some ( path) = m. value_of ( "path" ) {
939
+ PathBuf :: from ( path)
940
+ } else {
941
+ utils:: current_dir ( ) ?
942
+ } ;
943
+ toolchain. make_override ( & path) ?;
933
944
934
945
if let Some ( status) = status {
935
946
println ! ( ) ;
@@ -958,8 +969,8 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
958
969
}
959
970
list
960
971
} else {
961
- if m . is_present ( "path" ) {
962
- vec ! [ m . value_of ( " path" ) . unwrap ( ) . to_string( ) ]
972
+ if let Some ( path ) = m . value_of ( "path" ) {
973
+ vec ! [ path. to_string( ) ]
963
974
} else {
964
975
vec ! [ utils:: current_dir( ) ?. to_str( ) . unwrap( ) . to_string( ) ]
965
976
}
0 commit comments