diff options
Diffstat (limited to 'zellij-utils/src/input/command.rs')
-rw-r--r-- | zellij-utils/src/input/command.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs index 3212d26ec..c05aa644a 100644 --- a/zellij-utils/src/input/command.rs +++ b/zellij-utils/src/input/command.rs @@ -10,6 +10,19 @@ pub enum TerminalAction { RunCommand(RunCommand), } +impl TerminalAction { + pub fn change_cwd(&mut self, new_cwd: PathBuf) { + match self { + TerminalAction::OpenFile(_, _, cwd) => { + *cwd = Some(new_cwd); + }, + TerminalAction::RunCommand(run_command) => { + run_command.cwd = Some(new_cwd); + }, + } + } +} + #[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)] pub struct RunCommand { #[serde(alias = "cmd")] @@ -69,6 +82,19 @@ impl From<RunCommandAction> for RunCommand { } } +impl From<RunCommand> for RunCommandAction { + fn from(run_command: RunCommand) -> Self { + RunCommandAction { + command: run_command.command, + args: run_command.args, + cwd: run_command.cwd, + direction: None, + hold_on_close: run_command.hold_on_close, + hold_on_start: run_command.hold_on_start, + } + } +} + impl RunCommand { pub fn new(command: PathBuf) -> Self { RunCommand { |