Skip to content

Commit 432d1f8

Browse files
committed
Add --no-editor
1 parent b5fbf59 commit 432d1f8

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Automatically open the current file if Rustlings is running in a VS Code terminal
88
- Automatically open the current file with `$EDITOR` in a new pane if Rustlings is running in [Zellij](https://zellij.dev)
9+
- New argument `--no-editor` to disable automatic opening of the current file in VS Code or Zellij
910
- New argument `--edit-cmd` to communicate with an editor running in a different process to open the current exercise
1011
- Show the file link of the current exercise when running `rustlings hint` and `rustlings reset`
1112

src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ use crate::dev::DevCommand;
88
pub struct Args {
99
#[command(subcommand)]
1010
pub command: Option<Command>,
11+
/// Disable automatic opening of the current file in VS Code or Zellij.
12+
/// Ignores `--edit-cmd`
13+
#[arg(long)]
14+
pub no_editor: bool,
1115
/// Open the current exercise by running `EDIT_CMD EXERCISE_PATH`.
1216
/// The command is not allowed to block (e.g. `vim`).
1317
/// It should communicate with an editor in a different process.

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ fn main() -> Result<ExitCode> {
6262
}
6363

6464
let vs_code_term = env::var_os("TERM_PROGRAM").is_some_and(|v| v == "vscode");
65-
let editor = Editor::new(args.edit_cmd, vs_code_term)?;
65+
let editor = if args.no_editor {
66+
None
67+
} else {
68+
Editor::new(args.edit_cmd, vs_code_term)?
69+
};
70+
6671
let (mut app_state, state_file_status) = AppState::new(
6772
info_file.exercises,
6873
info_file.final_message.unwrap_or_default(),

0 commit comments

Comments
 (0)