Merge pull request #123 from kisom/master

Be nicer when rustlings isn't run from the right directory.
This commit is contained in:
komaeda 2019-03-17 22:28:03 +01:00 committed by GitHub
commit bf8d927ab2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();
} }