feat: commandline edit --accept to instantly execute command (#16193)

# Description

Fixes 
- #11065

Revised 
- #15092

Depends on

- https://github.com/nushell/reedline/pull/933

Adds the `--accept` flag to the `commandline` command, to immediately
accept the input.

Example use case: atuin

# User-facing changes

Users get the ability to pass `--accept` or `-A` to `commandline edit`
in order to immediately execute the resulting commandline.

# Tests + Formatting

I added two test cases that execute `commandline edit -A`.
There is also some documentation about their unintuitive expectations
output.

# After Submitting

The [docs](https://www.nushell.sh/commands/docs/commandline_edit.html)
can be updated to the new flag:

--accept, -A: immediately execute the command (no additional return
required)

> [!NOTE]
>
> This PR will be revised if / when
https://github.com/nushell/reedline/pull/933 is accepted

# Demo


[![asciicast](https://asciinema.org/a/Ql4r1oWu8J0C4MecmIZjxw5Pg.svg)](https://asciinema.org/a/Ql4r1oWu8J0C4MecmIZjxw5Pg)
This commit is contained in:
Stuart Carnie
2025-08-18 06:24:17 +10:00
committed by GitHub
parent a40f6d5cba
commit fd4a04211a
4 changed files with 33 additions and 3 deletions

View File

@@ -26,6 +26,11 @@ impl Command for CommandlineEdit {
"replaces the current contents of the buffer (default)",
Some('r'),
)
.switch(
"accept",
"immediately executes the result after edit",
Some('A'),
)
.required(
"str",
SyntaxShape::String,
@@ -61,6 +66,9 @@ impl Command for CommandlineEdit {
repl.buffer = str;
repl.cursor_pos = repl.buffer.len();
}
repl.accept = call.has_flag(engine_state, stack, "accept")?;
Ok(Value::nothing(call.head).into_pipeline_data())
}
}