Skip to content

Commit c5a06e9

Browse files
authored
Merge pull request #2100 from kinnison/kinnison/deprecation
Mark `rustup {un,}install` deprecated and report that
2 parents faae826 + 6ab9b4f commit c5a06e9

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/cli/rustup_mode.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ fn handle_epipe(res: Result<()>) -> Result<()> {
2727
}
2828
}
2929

30+
fn deprecated<F, A, B>(instead: &str, cfg: A, matches: B, callee: F) -> Result<()>
31+
where
32+
F: FnOnce(A, B) -> Result<()>,
33+
{
34+
warn!("Use of deprecated command line interface.");
35+
warn!(" Please use `rustup {}` instead", instead);
36+
callee(cfg, matches)
37+
}
38+
3039
pub fn main() -> Result<()> {
3140
crate::self_update::cleanup_self_updater()?;
3241

@@ -54,10 +63,10 @@ pub fn main() -> Result<()> {
5463
("keys", Some(_)) => handle_epipe(show_keys(cfg))?,
5564
(_, _) => handle_epipe(show(cfg))?,
5665
},
57-
("install", Some(m)) => update(cfg, m)?,
66+
("install", Some(m)) => deprecated("toolchain install", cfg, m, update)?,
5867
("update", Some(m)) => update(cfg, m)?,
5968
("check", Some(_)) => check_updates(cfg)?,
60-
("uninstall", Some(m)) => toolchain_remove(cfg, m)?,
69+
("uninstall", Some(m)) => deprecated("toolchain uninstall", &*cfg, m, toolchain_remove)?,
6170
("default", Some(m)) => default_(cfg, m)?,
6271
("toolchain", Some(c)) => match c.subcommand() {
6372
("install", Some(m)) => update(cfg, m)?,

tests/cli-misc.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pub mod mock;
55

66
use crate::mock::clitools::{
77
self, expect_component_executable, expect_component_not_executable, expect_err, expect_ok,
8-
expect_ok_eq, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run, set_current_dist_date,
9-
this_host_triple, Config, Scenario,
8+
expect_ok_contains, expect_ok_eq, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run,
9+
set_current_dist_date, this_host_triple, Config, Scenario,
1010
};
1111
use rustup::utils::{raw, utils};
1212

@@ -997,3 +997,21 @@ fn toolchain_link_then_list_verbose() {
997997
expect_stdout_ok(config, &["rustup", "toolchain", "list", "-v"], "/custom-1");
998998
});
999999
}
1000+
1001+
#[test]
1002+
fn deprecated_interfaces() {
1003+
setup(&|config| {
1004+
expect_ok_contains(
1005+
config,
1006+
&["rustup", "install", "nightly", "--no-self-update"],
1007+
"",
1008+
"Please use `rustup toolchain install` instead",
1009+
);
1010+
expect_ok_contains(
1011+
config,
1012+
&["rustup", "uninstall", "nightly"],
1013+
"",
1014+
"Please use `rustup toolchain uninstall` instead",
1015+
);
1016+
})
1017+
}

0 commit comments

Comments
 (0)