mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 23:04:17 -05:00
Be nicer when rustlings isn't run from the right directory.
Before, rustlings would panic if it wasn't in the right directory. It took me a minute to figure out why, and this wasn't my first intro to Rust. It would probably help new users if they saw a helpful message instead of a stack trace.
This commit is contained in:
parent
8f9d7ce3d8
commit
9fc4a83987
1 changed files with 9 additions and 0 deletions
|
@ -5,6 +5,7 @@ use notify::DebouncedEvent;
|
||||||
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
|
use std::path::Path;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use syntect::easy::HighlightFile;
|
use syntect::easy::HighlightFile;
|
||||||
|
@ -47,6 +48,14 @@ fn main() {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !Path::new("info.toml").exists() {
|
||||||
|
println!(
|
||||||
|
"{} must be run from the rustlings directory",
|
||||||
|
std::env::current_exe().unwrap().to_str().unwrap()
|
||||||
|
);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(matches) = matches.subcommand_matches("run") {
|
if let Some(matches) = matches.subcommand_matches("run") {
|
||||||
run(matches.clone()).unwrap();
|
run(matches.clone()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue