mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-22 05:52:23 -05:00
Formatting
This commit is contained in:
parent
f36efae25d
commit
ed0fcf8e3d
2 changed files with 17 additions and 22 deletions
|
@ -223,10 +223,7 @@ fn main() {
|
||||||
|
|
||||||
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}");
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn verify<'a>(
|
||||||
.progress_chars("#>-"),
|
.progress_chars("#>-"),
|
||||||
);
|
);
|
||||||
bar.set_position(num_done as u64);
|
bar.set_position(num_done as u64);
|
||||||
bar.set_message(format!("({:.1} %)", percentage));
|
bar.set_message(format!("({percentage:.1} %)"));
|
||||||
|
|
||||||
for exercise in exercises {
|
for exercise in exercises {
|
||||||
let compile_result = match exercise.mode {
|
let compile_result = match exercise.mode {
|
||||||
|
@ -37,7 +37,7 @@ pub fn verify<'a>(
|
||||||
}
|
}
|
||||||
percentage += 100.0 / total as f32;
|
percentage += 100.0 / total as f32;
|
||||||
bar.inc(1);
|
bar.inc(1);
|
||||||
bar.set_message(format!("({:.1} %)", percentage));
|
bar.set_message(format!("({percentage:.1} %)"));
|
||||||
if bar.position() == total as u64 {
|
if bar.position() == total as u64 {
|
||||||
println!(
|
println!(
|
||||||
"Progress: You completed {} / {} exercises ({:.1} %).",
|
"Progress: You completed {} / {} exercises ({:.1} %).",
|
||||||
|
@ -191,27 +191,25 @@ fn prompt_for_completion(
|
||||||
Mode::Test => "The code is compiling, and the tests pass!",
|
Mode::Test => "The code is compiling, and the tests pass!",
|
||||||
Mode::Clippy => clippy_success_msg,
|
Mode::Clippy => clippy_success_msg,
|
||||||
};
|
};
|
||||||
println!();
|
|
||||||
if no_emoji {
|
if no_emoji {
|
||||||
println!("~*~ {success_msg} ~*~")
|
println!("\n~*~ {success_msg} ~*~\n");
|
||||||
} else {
|
} else {
|
||||||
println!("🎉 🎉 {success_msg} 🎉 🎉")
|
println!("\n🎉 🎉 {success_msg} 🎉 🎉\n");
|
||||||
}
|
}
|
||||||
println!();
|
|
||||||
|
|
||||||
if let Some(output) = prompt_output {
|
if let Some(output) = prompt_output {
|
||||||
println!("Output:");
|
println!(
|
||||||
println!("{}", separator());
|
"Output:\n{separator}\n{output}\n{separator}\n",
|
||||||
println!("{output}");
|
separator = separator(),
|
||||||
println!("{}", separator());
|
);
|
||||||
println!();
|
|
||||||
}
|
}
|
||||||
if success_hints {
|
if success_hints {
|
||||||
println!("Hints:");
|
println!(
|
||||||
println!("{}", separator());
|
"Hints:\n{separator}\n{}\n{separator}\n",
|
||||||
println!("{}", exercise.hint);
|
exercise.hint,
|
||||||
println!("{}", separator());
|
separator = separator(),
|
||||||
println!();
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("You can keep working on this exercise,");
|
println!("You can keep working on this exercise,");
|
||||||
|
@ -231,7 +229,7 @@ fn prompt_for_completion(
|
||||||
"{:>2} {} {}",
|
"{:>2} {} {}",
|
||||||
style(context_line.number).blue().bold(),
|
style(context_line.number).blue().bold(),
|
||||||
style("|").blue(),
|
style("|").blue(),
|
||||||
formatted_line
|
formatted_line,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue