Skip to content

Commit

Permalink
update code after unblocked by rust-lang#96501 merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bentongxyz committed Oct 19, 2022
1 parent 8f8d901 commit 6ecd9ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ impl<'a> Builder<'a> {
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
Subcommand::Run { ref paths } => (Kind::Run, &paths[..]),
Subcommand::Format { .. } => (Kind::Format, &[][..]),
Subcommand::Setup { ref path } => (Kind::Setup, if let Some(p) = path { std::slice::from_ref(p) } else { &[] }),
Subcommand::Setup { ref paths } => (Kind::Setup, &paths[..]),
Subcommand::Clean { .. } => {
panic!()
}
Expand Down
25 changes: 3 additions & 22 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub enum Subcommand {
paths: Vec<PathBuf>,
},
Setup {
path: Option<PathBuf>,
paths: Vec<PathBuf>,
},
}

Expand Down Expand Up @@ -543,7 +543,7 @@ Arguments:
Kind::Bench | Kind::Clean | Kind::Dist | Kind::Install => {}
};
// Get any optional paths which occur after the subcommand
let mut paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>();
let paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>();

let verbose = matches.opt_present("verbose");

Expand Down Expand Up @@ -614,26 +614,7 @@ Arguments:
}
Subcommand::Run { paths }
}
Kind::Setup => {
if paths.len() > 1 {
println!("\nat 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(
|path| format!("{} is not a valid UTF8 string", path.to_string_lossy())
));

profile_string.parse().unwrap_or_else(|err| {
eprintln!("error: {}", err);
eprintln!("help: the available profiles are:");
eprint!("{}", Profile::all_for_help("- "));
crate::detail_exit(1);
})
} else {
t!(crate::setup::interactive_path())
};
Subcommand::Setup { paths: vec![PathBuf::from(profile.as_str())] }
}
Kind::Setup => Subcommand::Setup { paths },
};

Flags {
Expand Down

0 comments on commit 6ecd9ee

Please sign in to comment.