Skip to content

Commit dd59773

Browse files
committed
add/remove multiple toolchains
1 parent 408ed84 commit dd59773

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,13 @@ pub fn cli() -> App<'static, 'static> {
158158
.subcommand(SubCommand::with_name("install")
159159
.about("Install or update a given toolchain")
160160
.arg(Arg::with_name("toolchain")
161-
.required(true)))
161+
.required(true)
162+
.multiple(true)))
162163
.subcommand(SubCommand::with_name("uninstall")
163164
.about("Uninstall a toolchain")
164165
.arg(Arg::with_name("toolchain")
165-
.required(true)))
166+
.required(true)
167+
.multiple(true)))
166168
.subcommand(SubCommand::with_name("link")
167169
.about("Create a custom toolchain by symlinking to a directory")
168170
.arg(Arg::with_name("toolchain")
@@ -172,15 +174,18 @@ pub fn cli() -> App<'static, 'static> {
172174
.subcommand(SubCommand::with_name("update")
173175
.setting(AppSettings::Hidden) // synonym for 'install'
174176
.arg(Arg::with_name("toolchain")
175-
.required(true)))
177+
.required(true)
178+
.multiple(true)))
176179
.subcommand(SubCommand::with_name("add")
177180
.setting(AppSettings::Hidden) // synonym for 'install'
178181
.arg(Arg::with_name("toolchain")
179-
.required(true)))
182+
.required(true)
183+
.multiple(true)))
180184
.subcommand(SubCommand::with_name("remove")
181185
.setting(AppSettings::Hidden) // synonym for 'uninstall'
182186
.arg(Arg::with_name("toolchain")
183-
.required(true))))
187+
.required(true)
188+
.multiple(true))))
184189
.subcommand(SubCommand::with_name("target")
185190
.about("Modify a toolchain's supported targets")
186191
.setting(AppSettings::VersionlessSubcommands)
@@ -458,21 +463,23 @@ fn default_(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
458463
}
459464

460465
fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
461-
if let Some(name) = m.value_of("toolchain") {
462-
try!(update_bare_triple_check(cfg, name));
463-
let toolchain = try!(cfg.get_toolchain(name, false));
464-
465-
let status = if !toolchain.is_custom() {
466-
Some(try!(toolchain.install_from_dist()))
467-
} else if !toolchain.exists() {
468-
return Err(ErrorKind::ToolchainNotInstalled(toolchain.name().to_string()).into());
469-
} else {
470-
None
471-
};
466+
if let Some(names) = m.values_of("toolchain") {
467+
for name in names {
468+
try!(update_bare_triple_check(cfg, name));
469+
let toolchain = try!(cfg.get_toolchain(name, false));
470+
471+
let status = if !toolchain.is_custom() {
472+
Some(try!(toolchain.install_from_dist()))
473+
} else if !toolchain.exists() {
474+
return Err(ErrorKind::ToolchainNotInstalled(toolchain.name().to_string()).into());
475+
} else {
476+
None
477+
};
472478

473-
if let Some(status) = status {
474-
println!("");
475-
try!(common::show_channel_update(cfg, toolchain.name(), Ok(status)));
479+
if let Some(status) = status {
480+
println!("");
481+
try!(common::show_channel_update(cfg, toolchain.name(), Ok(status)));
482+
}
476483
}
477484
} else {
478485
try!(common::update_all_channels(cfg, !m.is_present("no-self-update") && !self_update::NEVER_SELF_UPDATE));
@@ -684,10 +691,11 @@ fn toolchain_link(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
684691
}
685692

686693
fn toolchain_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
687-
let ref toolchain = m.value_of("toolchain").expect("");
688-
let toolchain = try!(cfg.get_toolchain(toolchain, false));
689-
690-
Ok(try!(toolchain.remove()))
694+
for toolchain in m.values_of("toolchain").expect("") {
695+
let toolchain = try!(cfg.get_toolchain(toolchain, false));
696+
try!(toolchain.remove());
697+
}
698+
Ok(())
691699
}
692700

693701
fn override_add(cfg: &Cfg, m: &ArgMatches) -> Result<()> {

0 commit comments

Comments
 (0)