Catch the usage of the old method

This commit is contained in:
mo8it 2024-04-21 19:34:55 +02:00
parent 04d36996dd
commit 49e4a1fab0
2 changed files with 10 additions and 0 deletions

1
dev/rustlings-repo.txt Normal file
View file

@ -0,0 +1 @@
This file is used to check if the user tries to run Rustlings in the repository (the method before v6)

View file

@ -75,6 +75,10 @@ enum Subcommands {
fn main() -> Result<()> { fn main() -> Result<()> {
let args = Args::parse(); 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)?; which::which("cargo").context(CARGO_NOT_FOUND_ERR)?;
match args.command { match args.command {
@ -174,6 +178,11 @@ fn main() -> Result<()> {
Ok(()) 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`. const CARGO_NOT_FOUND_ERR: &str = "Failed to find `cargo`.
Did you already install Rust? Did you already install Rust?
Try running `cargo --version` to diagnose the problem."; Try running `cargo --version` to diagnose the problem.";