@@ -11,7 +11,7 @@ use rustup::{command, Cfg, Toolchain};
1111use std:: error:: Error ;
1212use std:: io:: { self , Write } ;
1313use std:: iter;
14- use std:: path:: Path ;
14+ use std:: path:: { Path , PathBuf } ;
1515use std:: process:: { self , Command } ;
1616
1717fn handle_epipe ( res : Result < ( ) > ) -> Result < ( ) > {
@@ -348,6 +348,12 @@ pub fn cli() -> App<'static, 'static> {
348348 Arg :: with_name ( "toolchain" )
349349 . help ( TOOLCHAIN_ARG_HELP )
350350 . required ( true ) ,
351+ )
352+ . arg (
353+ Arg :: with_name ( "path" )
354+ . long ( "path" )
355+ . takes_value ( true )
356+ . help ( "Path to the directory" ) ,
351357 ) ,
352358 )
353359 . subcommand (
@@ -929,7 +935,12 @@ fn override_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
929935 None
930936 } ;
931937
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) ?;
933944
934945 if let Some ( status) = status {
935946 println ! ( ) ;
@@ -958,8 +969,8 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
958969 }
959970 list
960971 } 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( ) ]
963974 } else {
964975 vec ! [ utils:: current_dir( ) ?. to_str( ) . unwrap( ) . to_string( ) ]
965976 }
0 commit comments