Skip to content

Commit 0d2ed2c

Browse files
committed
update code as per comments
1 parent 6ecd9ee commit 0d2ed2c

File tree

4 files changed

+24
-66
lines changed

4 files changed

+24
-66
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/bootstrap/builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,11 @@ impl<'a> ShouldRun<'a> {
437437

438438
// single alias, which does not correspond to any on-disk path
439439
pub fn alias(mut self, alias: &str) -> Self {
440-
// exceptional case for `Kind::Setup` because its `library`
440+
// exceptional case for `Kind::Setup` because its `library`
441441
// and `compiler` options would otherwise naively match with
442442
// `compiler` and `library` folders respectively.
443443
assert!(
444-
self.kind == Kind::Setup
445-
|| !self.builder.src.join(alias).exists(),
444+
self.kind == Kind::Setup || !self.builder.src.join(alias).exists(),
446445
"use `builder.path()` for real paths: {}",
447446
alias
448447
);

src/bootstrap/flags.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use getopts::Options;
1010
use crate::builder::{Builder, Kind};
1111
use crate::config::{Config, TargetSelection};
1212
use crate::setup::Profile;
13+
use crate::util::t;
1314
use 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!("\nat 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

Comments
 (0)