option success_hints added to the struct Watchargs instead of Args
This commit is contained in:
parent
5d3696a9e6
commit
c44e3025f9
14
src/main.rs
14
src/main.rs
|
@ -37,9 +37,6 @@ struct Args {
|
||||||
/// show the executable version
|
/// show the executable version
|
||||||
#[argh(switch, short = 'v')]
|
#[argh(switch, short = 'v')]
|
||||||
version: bool,
|
version: bool,
|
||||||
/// show hints on success
|
|
||||||
#[argh(switch)]
|
|
||||||
success_hints: bool,
|
|
||||||
#[argh(subcommand)]
|
#[argh(subcommand)]
|
||||||
nested: Option<Subcommands>,
|
nested: Option<Subcommands>,
|
||||||
}
|
}
|
||||||
|
@ -64,7 +61,11 @@ struct VerifyArgs {}
|
||||||
#[derive(FromArgs, PartialEq, Debug)]
|
#[derive(FromArgs, PartialEq, Debug)]
|
||||||
#[argh(subcommand, name = "watch")]
|
#[argh(subcommand, name = "watch")]
|
||||||
/// Reruns `verify` when files were edited
|
/// Reruns `verify` when files were edited
|
||||||
struct WatchArgs {}
|
struct WatchArgs {
|
||||||
|
/// show hints on success
|
||||||
|
#[argh(switch)]
|
||||||
|
success_hints: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(FromArgs, PartialEq, Debug)]
|
#[derive(FromArgs, PartialEq, Debug)]
|
||||||
#[argh(subcommand, name = "run")]
|
#[argh(subcommand, name = "run")]
|
||||||
|
@ -151,7 +152,6 @@ fn main() {
|
||||||
let toml_str = &fs::read_to_string("info.toml").unwrap();
|
let toml_str = &fs::read_to_string("info.toml").unwrap();
|
||||||
let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises;
|
let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises;
|
||||||
let verbose = args.nocapture;
|
let verbose = args.nocapture;
|
||||||
let success_hints = args.success_hints;
|
|
||||||
|
|
||||||
let command = args.nested.unwrap_or_else(|| {
|
let command = args.nested.unwrap_or_else(|| {
|
||||||
println!("{DEFAULT_OUT}\n");
|
println!("{DEFAULT_OUT}\n");
|
||||||
|
@ -233,7 +233,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Subcommands::Verify(_subargs) => {
|
Subcommands::Verify(_subargs) => {
|
||||||
verify(&exercises, (0, exercises.len()), verbose, success_hints)
|
verify(&exercises, (0, exercises.len()), verbose, false)
|
||||||
.unwrap_or_else(|_| std::process::exit(1));
|
.unwrap_or_else(|_| std::process::exit(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Subcommands::Watch(_subargs) => match watch(&exercises, verbose, success_hints) {
|
Subcommands::Watch(_subargs) => match watch(&exercises, verbose, _subargs.success_hints) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!(
|
println!(
|
||||||
"Error: Could not watch your progress. Error message was {:?}.",
|
"Error: Could not watch your progress. Error message was {:?}.",
|
||||||
|
|
Loading…
Reference in New Issue