Add --no-editor

This commit is contained in:
mo8it 2026-04-07 00:07:41 +02:00
parent b5fbf59c0c
commit 432d1f84ea
3 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@
- Automatically open the current file if Rustlings is running in a VS Code terminal - 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) - 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 - 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` - Show the file link of the current exercise when running `rustlings hint` and `rustlings reset`

View File

@ -8,6 +8,10 @@ use crate::dev::DevCommand;
pub struct Args { pub struct Args {
#[command(subcommand)] #[command(subcommand)]
pub command: Option<Command>, pub command: Option<Command>,
/// 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`. /// Open the current exercise by running `EDIT_CMD EXERCISE_PATH`.
/// The command is not allowed to block (e.g. `vim`). /// The command is not allowed to block (e.g. `vim`).
/// It should communicate with an editor in a different process. /// It should communicate with an editor in a different process.

View File

@ -62,7 +62,12 @@ fn main() -> Result<ExitCode> {
} }
let vs_code_term = env::var_os("TERM_PROGRAM").is_some_and(|v| v == "vscode"); 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( let (mut app_state, state_file_status) = AppState::new(
info_file.exercises, info_file.exercises,
info_file.final_message.unwrap_or_default(), info_file.final_message.unwrap_or_default(),