@@ -10,6 +10,7 @@ use getopts::Options;
10
10
use crate :: builder:: { Builder , Kind } ;
11
11
use crate :: config:: { Config , TargetSelection } ;
12
12
use crate :: setup:: Profile ;
13
+ use crate :: util:: t;
13
14
use crate :: { Build , DocTests } ;
14
15
15
16
#[ derive( Copy , Clone ) ]
@@ -543,7 +544,7 @@ Arguments:
543
544
Kind :: Bench | Kind :: Clean | Kind :: Dist | Kind :: Install => { }
544
545
} ;
545
546
// 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 > > ( ) ;
547
548
548
549
let verbose = matches. opt_present ( "verbose" ) ;
549
550
@@ -614,7 +615,26 @@ Arguments:
614
615
}
615
616
Subcommand :: Run { paths }
616
617
}
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
+ }
618
638
} ;
619
639
620
640
Flags {
0 commit comments