From 432d1f84ea68d21e865215281764094a73236da0 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 7 Apr 2026 00:07:41 +0200 Subject: [PATCH] Add --no-editor --- CHANGELOG.md | 1 + src/cli.rs | 4 ++++ src/main.rs | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d2f003f..cdcdbb14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Automatically open the current file if Rustlings is running in a VS Code terminal - Automatically open the current file with `$EDITOR` in a new pane if Rustlings is running in [Zellij](https://zellij.dev) +- New argument `--no-editor` to disable automatic opening of the current file in VS Code or Zellij - New argument `--edit-cmd` to communicate with an editor running in a different process to open the current exercise - Show the file link of the current exercise when running `rustlings hint` and `rustlings reset` diff --git a/src/cli.rs b/src/cli.rs index 5830cbed..153994be 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,6 +8,10 @@ use crate::dev::DevCommand; pub struct Args { #[command(subcommand)] pub command: Option, + /// Disable automatic opening of the current file in VS Code or Zellij. + /// Ignores `--edit-cmd` + #[arg(long)] + pub no_editor: bool, /// Open the current exercise by running `EDIT_CMD EXERCISE_PATH`. /// The command is not allowed to block (e.g. `vim`). /// It should communicate with an editor in a different process. diff --git a/src/main.rs b/src/main.rs index 0fa9b75d..8da36f7f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,12 @@ fn main() -> Result { } let vs_code_term = env::var_os("TERM_PROGRAM").is_some_and(|v| v == "vscode"); - let editor = Editor::new(args.edit_cmd, vs_code_term)?; + let editor = if args.no_editor { + None + } else { + Editor::new(args.edit_cmd, vs_code_term)? + }; + let (mut app_state, state_file_status) = AppState::new( info_file.exercises, info_file.final_message.unwrap_or_default(),