|
|
@ -217,16 +217,13 @@ fn main() {
|
|
|
|
println!("Failed to write rust-project.json to disk for rust-analyzer");
|
|
|
|
println!("Failed to write rust-project.json to disk for rust-analyzer");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
println!("Successfully generated rust-project.json");
|
|
|
|
println!("Successfully generated rust-project.json");
|
|
|
|
println!("rust-analyzer will now parse exercises, restart your language server or editor")
|
|
|
|
println!("rust-analyzer will now parse exercises, restart your language server or editor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Subcommands::Watch { success_hints } => match watch(&exercises, verbose, success_hints) {
|
|
|
|
Subcommands::Watch { success_hints } => match watch(&exercises, verbose, success_hints) {
|
|
|
|
Err(e) => {
|
|
|
|
Err(e) => {
|
|
|
|
println!(
|
|
|
|
println!("Error: Could not watch your progress. Error message was {e:?}.");
|
|
|
|
"Error: Could not watch your progress. Error message was {:?}.",
|
|
|
|
|
|
|
|
e
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
println!("Most likely you've run out of disk space or your 'inotify limit' has been reached.");
|
|
|
|
println!("Most likely you've run out of disk space or your 'inotify limit' has been reached.");
|
|
|
|
std::process::exit(1);
|
|
|
|
std::process::exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -280,7 +277,7 @@ fn spawn_watch_shell(
|
|
|
|
if parts.is_empty() {
|
|
|
|
if parts.is_empty() {
|
|
|
|
println!("no command provided");
|
|
|
|
println!("no command provided");
|
|
|
|
} else if let Err(e) = Command::new(parts[0]).args(&parts[1..]).status() {
|
|
|
|
} else if let Err(e) = Command::new(parts[0]).args(&parts[1..]).status() {
|
|
|
|
println!("failed to execute command `{}`: {}", cmd, e);
|
|
|
|
println!("failed to execute command `{cmd}`: {e}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
println!("unknown command: {input}");
|
|
|
|
println!("unknown command: {input}");
|
|
|
@ -292,7 +289,7 @@ fn spawn_watch_shell(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
|
|
|
|
fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
|
|
|
|
if name.eq("next") {
|
|
|
|
if name == "next" {
|
|
|
|
exercises
|
|
|
|
exercises
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.find(|e| !e.looks_done())
|
|
|
|
.find(|e| !e.looks_done())
|
|
|
@ -338,7 +335,6 @@ fn watch(
|
|
|
|
|
|
|
|
|
|
|
|
clear_screen();
|
|
|
|
clear_screen();
|
|
|
|
|
|
|
|
|
|
|
|
let to_owned_hint = |t: &Exercise| t.hint.to_owned();
|
|
|
|
|
|
|
|
let failed_exercise_hint = match verify(
|
|
|
|
let failed_exercise_hint = match verify(
|
|
|
|
exercises.iter(),
|
|
|
|
exercises.iter(),
|
|
|
|
(0, exercises.len()),
|
|
|
|
(0, exercises.len()),
|
|
|
@ -346,7 +342,7 @@ fn watch(
|
|
|
|
success_hints,
|
|
|
|
success_hints,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Ok(_) => return Ok(WatchStatus::Finished),
|
|
|
|
Ok(_) => return Ok(WatchStatus::Finished),
|
|
|
|
Err(exercise) => Arc::new(Mutex::new(Some(to_owned_hint(exercise)))),
|
|
|
|
Err(exercise) => Arc::new(Mutex::new(Some(exercise.hint.clone()))),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
spawn_watch_shell(&failed_exercise_hint, Arc::clone(&should_quit));
|
|
|
|
spawn_watch_shell(&failed_exercise_hint, Arc::clone(&should_quit));
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
@ -383,7 +379,7 @@ fn watch(
|
|
|
|
Err(exercise) => {
|
|
|
|
Err(exercise) => {
|
|
|
|
let mut failed_exercise_hint =
|
|
|
|
let mut failed_exercise_hint =
|
|
|
|
failed_exercise_hint.lock().unwrap();
|
|
|
|
failed_exercise_hint.lock().unwrap();
|
|
|
|
*failed_exercise_hint = Some(to_owned_hint(exercise));
|
|
|
|
*failed_exercise_hint = Some(exercise.hint.clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -415,7 +411,7 @@ fn rustc_exists() -> bool {
|
|
|
|
.unwrap_or(false)
|
|
|
|
.unwrap_or(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const DEFAULT_OUT: &str = r#"Thanks for installing Rustlings!
|
|
|
|
const DEFAULT_OUT: &str = "Thanks for installing Rustlings!
|
|
|
|
|
|
|
|
|
|
|
|
Is this your first time? Don't worry, Rustlings was made for beginners! We are
|
|
|
|
Is this your first time? Don't worry, Rustlings was made for beginners! We are
|
|
|
|
going to teach you a lot of things about Rust, but before we can get
|
|
|
|
going to teach you a lot of things about Rust, but before we can get
|
|
|
@ -441,7 +437,7 @@ started, here's a couple of notes about how Rustlings operates:
|
|
|
|
autocompletion, run the command `rustlings lsp`.
|
|
|
|
autocompletion, run the command `rustlings lsp`.
|
|
|
|
|
|
|
|
|
|
|
|
Got all that? Great! To get started, run `rustlings watch` in order to get the first
|
|
|
|
Got all that? Great! To get started, run `rustlings watch` in order to get the first
|
|
|
|
exercise. Make sure to have your editor open!"#;
|
|
|
|
exercise. Make sure to have your editor open!";
|
|
|
|
|
|
|
|
|
|
|
|
const FENISH_LINE: &str = "+----------------------------------------------------+
|
|
|
|
const FENISH_LINE: &str = "+----------------------------------------------------+
|
|
|
|
| You made it to the Fe-nish line! |
|
|
|
|
| You made it to the Fe-nish line! |
|
|
|
|