aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/input/command.rs
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-06-30 23:25:50 +0200
committera-kenji <aks.kenji@protonmail.com>2021-07-02 13:39:02 +0200
commit0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee (patch)
treec9a3a2b23fb4ef07fccdd82620eadfb99b11fcd0 /zellij-utils/src/input/command.rs
parentMerge pull request #593 from a-kenji/modularize-spawn-terminal (diff)
downloadsl0ppij-0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee.tar.gz
sl0ppij-0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee.tar.xz
sl0ppij-0bf78100ddbae4fa3f199b4c0f4a4b05ac83c5ee.zip
Add running commands to an action
Add the ability to bind running commands to an action. Eg: ``` - action: [Run: {command: "htop",},] key: [F: 6,] `` Optionally the direction and arguments can be specified: ``` - action: [Run: {command: "htop", args: ["-C",]},] key: [F: 7,] ``` The directional splits are analogous to the `[NewPane]` splits. ``` - action: [Run: {command: "htop", args: ["-C",], direction: "Up"},] key: [F: 8,] ```
Diffstat (limited to 'zellij-utils/src/input/command.rs')
-rw-r--r--zellij-utils/src/input/command.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs
index 79bbe5ab..ca505ea2 100644
--- a/zellij-utils/src/input/command.rs
+++ b/zellij-utils/src/input/command.rs
@@ -1,4 +1,5 @@
//! Trigger a command
+use super::actions::Direction;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
@@ -8,9 +9,28 @@ pub enum TerminalAction {
RunCommand(RunCommand),
}
-#[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq)]
+#[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)]
pub struct RunCommand {
pub command: PathBuf,
#[serde(default)]
pub args: Vec<String>,
}
+
+/// Intermediate representation
+#[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)]
+pub struct RunCommandAction {
+ pub command: PathBuf,
+ #[serde(default)]
+ pub args: Vec<String>,
+ #[serde(default)]
+ pub direction: Option<Direction>,
+}
+
+impl From<RunCommandAction> for RunCommand {
+ fn from(action: RunCommandAction) -> Self {
+ RunCommand {
+ command: action.command,
+ args: action.args,
+ }
+ }
+}