mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-03-16 21:15:01 +00:00
Compare commits
1 commit
779f60ee94
...
3f4383cedb
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3f4383cedb |
1 changed files with 0 additions and 36 deletions
36
src/main.rs
36
src/main.rs
|
@ -1,10 +1,6 @@
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use app_state::StateFileStatus;
|
use app_state::StateFileStatus;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use crossterm::{
|
|
||||||
style::{Color, Print, ResetColor, SetForegroundColor},
|
|
||||||
QueueableCommand,
|
|
||||||
};
|
|
||||||
use std::{
|
use std::{
|
||||||
io::{self, IsTerminal, Write},
|
io::{self, IsTerminal, Write},
|
||||||
path::Path,
|
path::Path,
|
||||||
|
@ -51,8 +47,6 @@ enum Subcommands {
|
||||||
/// The name of the exercise
|
/// The name of the exercise
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
},
|
},
|
||||||
/// Run all the exercises, marking them as done or pending accordingly.
|
|
||||||
RunAll,
|
|
||||||
/// Reset a single exercise
|
/// Reset a single exercise
|
||||||
Reset {
|
Reset {
|
||||||
/// The name of the exercise
|
/// The name of the exercise
|
||||||
|
@ -144,36 +138,6 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
run::run(&mut app_state)?;
|
run::run(&mut app_state)?;
|
||||||
}
|
}
|
||||||
Some(Subcommands::RunAll) => {
|
|
||||||
let mut stdout = io::stdout().lock();
|
|
||||||
if let Some(first_fail) = app_state.check_all_exercises(&mut stdout, false)? {
|
|
||||||
let pending = app_state
|
|
||||||
.exercises()
|
|
||||||
.iter()
|
|
||||||
.filter(|exercise| !exercise.done)
|
|
||||||
.count();
|
|
||||||
if app_state.current_exercise().done {
|
|
||||||
app_state.set_current_exercise_ind(first_fail)?;
|
|
||||||
}
|
|
||||||
stdout
|
|
||||||
.queue(Print("\n"))?
|
|
||||||
.queue(SetForegroundColor(Color::Red))?
|
|
||||||
.queue(Print(format!("{pending}")))?
|
|
||||||
.queue(ResetColor)?;
|
|
||||||
if pending == 1 {
|
|
||||||
stdout.queue(Print(" exercise has some errors: "))?;
|
|
||||||
} else {
|
|
||||||
stdout.queue(Print(" exercises have errors, including "))?;
|
|
||||||
}
|
|
||||||
app_state
|
|
||||||
.current_exercise()
|
|
||||||
.terminal_file_link(&mut stdout)?;
|
|
||||||
stdout.write_all(b".\n")?;
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
app_state.render_final_message(&mut stdout)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some(Subcommands::Reset { name }) => {
|
Some(Subcommands::Reset { name }) => {
|
||||||
app_state.set_current_exercise_by_name(&name)?;
|
app_state.set_current_exercise_by_name(&name)?;
|
||||||
let exercise_path = app_state.reset_current_exercise()?;
|
let exercise_path = app_state.reset_current_exercise()?;
|
||||||
|
|
Loading…
Reference in a new issue