@@ -12,7 +12,7 @@ use rustup_utils::utils::{self, ExitCode};
1212use std:: error:: Error ;
1313use std:: io:: { self , Write } ;
1414use std:: iter;
15- use std:: path:: Path ;
15+ use std:: path:: { Path , PathBuf } ;
1616use std:: process:: { self , Command } ;
1717
1818pub fn main ( ) -> Result < ( ) > {
@@ -341,6 +341,12 @@ pub fn cli() -> App<'static, 'static> {
341341 Arg :: with_name ( "toolchain" )
342342 . help ( TOOLCHAIN_ARG_HELP )
343343 . required ( true ) ,
344+ )
345+ . arg (
346+ Arg :: with_name ( "path" )
347+ . long ( "path" )
348+ . takes_value ( true )
349+ . help ( "Path to the directory" ) ,
344350 ) ,
345351 )
346352 . subcommand (
@@ -913,7 +919,12 @@ fn override_add(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
913919 None
914920 } ;
915921
916- toolchain. make_override ( & utils:: current_dir ( ) ?) ?;
922+ let path = if let Some ( path) = m. value_of ( "path" ) {
923+ PathBuf :: from ( path)
924+ } else {
925+ utils:: current_dir ( ) ?
926+ } ;
927+ toolchain. make_override ( & path) ?;
917928
918929 if let Some ( status) = status {
919930 println ! ( "" ) ;
@@ -942,8 +953,8 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
942953 }
943954 list
944955 } else {
945- if m . is_present ( "path" ) {
946- vec ! [ m . value_of ( " path" ) . unwrap ( ) . to_string( ) ]
956+ if let Some ( path ) = m . value_of ( "path" ) {
957+ vec ! [ path. to_string( ) ]
947958 } else {
948959 vec ! [ utils:: current_dir( ) ?. to_str( ) . unwrap( ) . to_string( ) ]
949960 }
0 commit comments