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/impl_comment.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/impl_comment.rs')
-rw-r--r-- | src/key_command/impl_comment.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/key_command/impl_comment.rs b/src/key_command/impl_comment.rs index 0483e85..bcfd3c9 100644 --- a/src/key_command/impl_comment.rs +++ b/src/key_command/impl_comment.rs @@ -3,6 +3,8 @@ use crate::{ io::FileOperationOptions, }; +use crate::commands::sub_process::SubprocessCallMode; + use super::{Command, CommandComment}; impl CommandComment for Command { @@ -104,8 +106,10 @@ impl CommandComment for Command { Self::SetCaseSensitivity { .. } => "Set case sensitivity", Self::SetMode => "Set file permissions", - Self::SubProcess { spawn: false, .. } => "Run a shell command", - Self::SubProcess { spawn: true, .. } => "Run command in background", + Self::SubProcess { mode: SubprocessCallMode::Interactive, .. } => "Run a shell command (blocking) and hand over shell temporarily", + Self::SubProcess { mode: SubprocessCallMode::Spawn, .. } => "Spawn a shell command", + Self::SubProcess { mode: SubprocessCallMode::Capture, .. } => "Run a shell command (blocking), do not hand over shall but capture stdout for post-processing", + Self::StdOutPostProcess { .. } => "Post process stdout of last `shell` command", Self::ShowTasks => "Show running background tasks", Self::ToggleHiddenFiles => "Toggle hidden files displaying", |