Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ fn handle_epipe(res: Result<()>) -> Result<()> {
}
}

fn deprecated<F, A, B>(instead: &str, cfg: A, matches: B, callee: F) -> Result<()>
where
F: FnOnce(A, B) -> Result<()>,
{
warn!("Use of deprecated command line interface.");
warn!(" Please use `rustup {}` instead", instead);
callee(cfg, matches)
}

pub fn main() -> Result<()> {
crate::self_update::cleanup_self_updater()?;

Expand All @@ -53,10 +62,10 @@ pub fn main() -> Result<()> {
("profile", Some(_)) => handle_epipe(show_profile(cfg))?,
(_, _) => handle_epipe(show(cfg))?,
},
("install", Some(m)) => update(cfg, m)?,
("install", Some(m)) => deprecated("toolchain install", cfg, m, update)?,
("update", Some(m)) => update(cfg, m)?,
("check", Some(_)) => check_updates(cfg)?,
("uninstall", Some(m)) => toolchain_remove(cfg, m)?,
("uninstall", Some(m)) => deprecated("toolchain uninstall", &*cfg, m, toolchain_remove)?,
("default", Some(m)) => default_(cfg, m)?,
("toolchain", Some(c)) => match c.subcommand() {
("install", Some(m)) => update(cfg, m)?,
Expand Down
22 changes: 20 additions & 2 deletions tests/cli-misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub mod mock;

use crate::mock::clitools::{
self, expect_component_executable, expect_component_not_executable, expect_err, expect_ok,
expect_ok_eq, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run, set_current_dist_date,
this_host_triple, Config, Scenario,
expect_ok_contains, expect_ok_eq, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run,
set_current_dist_date, this_host_triple, Config, Scenario,
};
use rustup::utils::{raw, utils};

Expand Down Expand Up @@ -997,3 +997,21 @@ fn toolchain_link_then_list_verbose() {
expect_stdout_ok(config, &["rustup", "toolchain", "list", "-v"], "/custom-1");
});
}

#[test]
fn deprecated_interfaces() {
setup(&|config| {
expect_ok_contains(
config,
&["rustup", "install", "nightly", "--no-self-update"],
"",
"Please use `rustup toolchain install` instead",
);
expect_ok_contains(
config,
&["rustup", "uninstall", "nightly"],
"",
"Please use `rustup toolchain uninstall` instead",
);
})
}