diff options
author | DLFW <daniel@llin.info> | 2024-03-10 20:07:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-10 15:07:10 -0400 |
commit | 2de86e369748b5f62e08ea1abb133f9816d60b8b (patch) | |
tree | 473787eab309916befb44c220e1aaac6b9905009 /src/key_command/command.rs | |
parent | dfbf093611d77e5d95c34f11a496f7f2001273ab (diff) |
Add `capture` and `stdout` commands (#495)
This adds two new commands as a base to enable users to use the output
of scripts to do certain actions in Joshuto.
The first command this adds is a third command to start a sub-process
beside `shell` and `spawn`, called `capture`. Like `shell`, `capture` is
running blocking but unlike `shell`, it does not release the terminal
but captures the `stdout` of the sub-process and stores it in an
`AppContext` attribute.
The second command added by this commit is `stdout`. This command takes
the output from the last `capture` run, stored in the `AppContext`
attribute, and uses it for some action. The action has to be specified
as a sub-command. As of now, only `stdout cd` is implemented. This
checks that the last output of `capture` is a single line of an existing
file or directory and then changes the working directory to that.
To get significant value from these new commands, `capture` needs to be
equipped with more variables to feed more information about Joshuto's
state into external scripts, and `stdout` needs to get some more
sub-commands.
Diffstat (limited to 'src/key_command/command.rs')
-rw-r--r-- | src/key_command/command.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/key_command/command.rs b/src/key_command/command.rs index fad1530..0a4736f 100644 --- a/src/key_command/command.rs +++ b/src/key_command/command.rs @@ -3,6 +3,8 @@ use std::path; use crate::commands::case_sensitivity::SetType; use crate::commands::quit::QuitAction; use crate::commands::select::SelectOption; +use crate::commands::stdout::PostProcessor; +use crate::commands::sub_process::SubprocessCallMode; use crate::config::clean::app::display::line_mode::LineMode; use crate::config::clean::app::display::line_number::LineNumberStyle; use crate::config::clean::app::display::new_tab::NewTabMode; @@ -137,7 +139,7 @@ pub enum Command { SetMode, SubProcess { words: Vec<String>, - spawn: bool, + mode: SubprocessCallMode, }, ShowTasks, @@ -181,6 +183,9 @@ pub enum Command { SelectFzf { options: SelectOption, }, + StdOutPostProcess { + processor: PostProcessor, + }, Zoxide(String), ZoxideInteractive, |