]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/flags.rs
rustdoc: combine common sidebar background color CSS rules
[rust.git] / src / bootstrap / flags.rs
index 37a8eb884efb02beba7ca57c462108a1bca96ae1..3be7ad4075ed8d8f621826d30375f8fdf99e9151 100644 (file)
@@ -130,6 +130,7 @@ pub enum Subcommand {
         test_args: Vec<String>,
     },
     Clean {
+        paths: Vec<PathBuf>,
         all: bool,
     },
     Dist {
@@ -143,7 +144,7 @@ pub enum Subcommand {
         args: Vec<String>,
     },
     Setup {
-        profile: Option<Profile>,
+        profile: Option<PathBuf>,
     },
 }
 
@@ -351,7 +352,17 @@ pub fn parse(args: &[String]) -> Flags {
 
         // fn usage()
         let usage = |exit_code: i32, opts: &Options, verbose: bool, subcommand_help: &str| -> ! {
-            let config = Config::parse(&["build".to_string()]);
+            // We have an unfortunate situation here: some Steps use `builder.in_tree_crates` to determine their paths.
+            // To determine those crates, we need to run `cargo metadata`, which means we need all submodules to be checked out.
+            // That takes a while to run, so only do it when paths were explicitly requested, not on all CLI errors.
+            // `Build::new` won't load submodules for the `setup` command.
+            let cmd = if verbose {
+                println!("note: updating submodules before printing available paths");
+                "build"
+            } else {
+                "setup"
+            };
+            let config = Config::parse(&[cmd.to_string()]);
             let build = Build::new(config);
             let paths = Builder::get_help(&build, subcommand);
 
@@ -601,14 +612,7 @@ pub fn parse(args: &[String]) -> Flags {
                 open: matches.opt_present("open"),
                 json: matches.opt_present("json"),
             },
-            Kind::Clean => {
-                if !paths.is_empty() {
-                    println!("\nclean does not take a path argument\n");
-                    usage(1, &opts, verbose, &subcommand_help);
-                }
-
-                Subcommand::Clean { all: matches.opt_present("all") }
-            }
+            Kind::Clean => Subcommand::Clean { all: matches.opt_present("all"), paths },
             Kind::Format => Subcommand::Format { check: matches.opt_present("check"), paths },
             Kind::Dist => Subcommand::Dist { paths },
             Kind::Install => Subcommand::Install { paths },
@@ -621,7 +625,7 @@ pub fn parse(args: &[String]) -> Flags {
             }
             Kind::Setup => {
                 let profile = if paths.len() > 1 {
-                    println!("\nat most one profile can be passed to setup\n");
+                    eprintln!("\nerror: At most one profile can be passed to setup\n");
                     usage(1, &opts, verbose, &subcommand_help)
                 } else if let Some(path) = paths.pop() {
                     let profile_string = t!(path.into_os_string().into_string().map_err(