@@ -10,6 +10,7 @@ use getopts::Options;
1010use crate :: builder:: { Builder , Kind } ;
1111use crate :: config:: { Config , TargetSelection } ;
1212use crate :: setup:: Profile ;
13+ use crate :: util:: t;
1314use crate :: { Build , DocTests } ;
1415
1516#[ derive( Copy , Clone ) ]
@@ -543,7 +544,7 @@ Arguments:
543544 Kind :: Bench | Kind :: Clean | Kind :: Dist | Kind :: Install => { }
544545 } ;
545546 // Get any optional paths which occur after the subcommand
546- let paths = matches. free [ 1 ..] . iter ( ) . map ( |p| p. into ( ) ) . collect :: < Vec < PathBuf > > ( ) ;
547+ let mut paths = matches. free [ 1 ..] . iter ( ) . map ( |p| p. into ( ) ) . collect :: < Vec < PathBuf > > ( ) ;
547548
548549 let verbose = matches. opt_present ( "verbose" ) ;
549550
@@ -614,7 +615,26 @@ Arguments:
614615 }
615616 Subcommand :: Run { paths }
616617 }
617- Kind :: Setup => Subcommand :: Setup { paths } ,
618+ Kind :: Setup => {
619+ let profile = if paths. len ( ) > 1 {
620+ println ! ( "\n at most one profile can be passed to setup\n " ) ;
621+ usage ( 1 , & opts, verbose, & subcommand_help)
622+ } else if let Some ( path) = paths. pop ( ) {
623+ let profile_string = t ! ( path. into_os_string( ) . into_string( ) . map_err(
624+ |path| format!( "{} is not a valid UTF8 string" , path. to_string_lossy( ) )
625+ ) ) ;
626+
627+ profile_string. parse ( ) . unwrap_or_else ( |err| {
628+ eprintln ! ( "error: {}" , err) ;
629+ eprintln ! ( "help: the available profiles are:" ) ;
630+ eprint ! ( "{}" , Profile :: all_for_help( "- " ) ) ;
631+ crate :: detail_exit ( 1 ) ;
632+ } )
633+ } else {
634+ t ! ( crate :: setup:: interactive_path( ) )
635+ } ;
636+ Subcommand :: Setup { paths : vec ! [ PathBuf :: from( profile. as_str( ) ) ] }
637+ }
618638 } ;
619639
620640 Flags {
0 commit comments