mirror of
https://github.com/nushell/nushell.git
synced 2025-08-26 19:09:01 +02:00
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 [](https://asciinema.org/a/Ql4r1oWu8J0C4MecmIZjxw5Pg)
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user