impl Flags {
pub fn parse(args: &[String]) -> Flags {
let mut extra_help = String::new();
- let mut subcommand_help = format!(
- "\
+ let mut subcommand_help = String::from("\
Usage: x.py <subcommand> [options] [<paths>...]
Subcommands:
opts.optopt("", "on-fail", "command to run on failure", "CMD");
opts.optflag("", "dry-run", "dry run; don't build anything");
opts.optopt("", "stage",
- "stage to build (indicates compiler to use/test, e.g. stage 0 uses the \
+ "stage to build (indicates compiler to use/test, e.g., stage 0 uses the \
bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)",
"N");
opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling \
- (pass multiple times to keep e.g. both stages 0 and 1)", "N");
+ (pass multiple times to keep e.g., both stages 0 and 1)", "N");
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
opts.optflag("h", "help", "print this help message");
}
let cmd = match subcommand.as_str() {
- "build" => Subcommand::Build { paths: paths },
- "check" => Subcommand::Check { paths: paths },
+ "build" => Subcommand::Build { paths },
+ "check" => Subcommand::Check { paths },
"test" => Subcommand::Test {
paths,
bless: matches.opt_present("bless"),
paths,
test_args: matches.opt_strs("test-args"),
},
- "doc" => Subcommand::Doc { paths: paths },
+ "doc" => Subcommand::Doc { paths },
"clean" => {
- if paths.len() > 0 {
+ if !paths.is_empty() {
println!("\nclean does not take a path argument\n");
usage(1, &opts, &subcommand_help, &extra_help);
}
keep_stage: matches.opt_strs("keep-stage")
.into_iter().map(|j| j.parse().unwrap())
.collect(),
- host: split(matches.opt_strs("host"))
+ host: split(&matches.opt_strs("host"))
.into_iter()
.map(|x| INTERNER.intern_string(x))
.collect::<Vec<_>>(),
- target: split(matches.opt_strs("target"))
+ target: split(&matches.opt_strs("target"))
.into_iter()
.map(|x| INTERNER.intern_string(x))
.collect::<Vec<_>>(),
jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()),
cmd,
incremental: matches.opt_present("incremental"),
- exclude: split(matches.opt_strs("exclude"))
+ exclude: split(&matches.opt_strs("exclude"))
.into_iter()
.map(|p| p.into())
.collect::<Vec<_>>(),
}
}
-fn split(s: Vec<String>) -> Vec<String> {
+fn split(s: &[String]) -> Vec<String> {
s.iter()
.flat_map(|s| s.split(','))
.map(|s| s.to_string())