diff options
| author | mo8it <mo8it@proton.me> | 2024-04-14 17:10:53 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-14 17:10:53 +0200 |
| commit | 1cbabc3d28a29a01caeffba969ed640e00e5f0be (patch) | |
| tree | 4bed65819c4a05e1d9cb088d9b3fd969398143d8 /src/main.rs | |
| parent | bd10b154fe558af693e9f8f57dbb3e43f0bd0ec8 (diff) | |
Add the manual-run option
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index 6796921..28a426b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,10 @@ use self::{ struct Args { #[command(subcommand)] command: Option<Subcommands>, + /// Manually run the current exercise using `r` or `run` in the watch mode. + /// Only use this if Rustlings fails to detect exercise file changes. + #[arg(long)] + manual_run: bool, } #[derive(Subcommand)] @@ -101,17 +105,23 @@ fn main() -> Result<()> { match args.command { None => { - // For the the notify event handler thread. - // Leaking is not a problem because the slice lives until the end of the program. - let exercise_paths = app_state - .exercises() - .iter() - .map(|exercise| exercise.path) - .collect::<Vec<_>>() - .leak(); + let notify_exercise_paths: Option<&'static [&'static str]> = if args.manual_run { + None + } else { + // For the the notify event handler thread. + // Leaking is not a problem because the slice lives until the end of the program. + Some( + app_state + .exercises() + .iter() + .map(|exercise| exercise.path) + .collect::<Vec<_>>() + .leak(), + ) + }; loop { - match watch(&mut app_state, exercise_paths)? { + match watch(&mut app_state, notify_exercise_paths)? { WatchExit::Shutdown => break, // It is much easier to exit the watch mode, launch the list mode and then restart // the watch mode instead of trying to pause the watch threads and correct the |
