From 49e4a1fab04560cf0e868ab8214dfc94e76b9f4b Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 21 Apr 2024 19:34:55 +0200 Subject: [PATCH] Catch the usage of the old method --- dev/rustlings-repo.txt | 1 + src/main.rs | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 dev/rustlings-repo.txt diff --git a/dev/rustlings-repo.txt b/dev/rustlings-repo.txt new file mode 100644 index 00000000..62793612 --- /dev/null +++ b/dev/rustlings-repo.txt @@ -0,0 +1 @@ +This file is used to check if the user tries to run Rustlings in the repository (the method before v6) diff --git a/src/main.rs b/src/main.rs index 69ac0a39..bf2498a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,6 +75,10 @@ enum Subcommands { fn main() -> Result<()> { let args = Args::parse(); + if !DEBUG_PROFILE && Path::new("dev/rustlings-repo.txt").exists() { + bail!("{OLD_METHOD_ERR}"); + } + which::which("cargo").context(CARGO_NOT_FOUND_ERR)?; match args.command { @@ -174,6 +178,11 @@ fn main() -> Result<()> { Ok(()) } +const OLD_METHOD_ERR: &str = "You are trying to run Rustlings using the old method before v6. +The new method doesn't include cloning the Rustlings' repository. +Please follow the instructions in the README: +https://github.com/rust-lang/rustlings#getting-started"; + const CARGO_NOT_FOUND_ERR: &str = "Failed to find `cargo`. Did you already install Rust? Try running `cargo --version` to diagnose the problem.";