gardesk/garterm / 8c4eaa6

Browse files

fix gartermctl: add exec/title to new-tab, cwd/exec to split, add load-session

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
8c4eaa6067d4ede3cf1c54ebba8de2dc17e59cfb
Parents
3759845
Tree
b44d8b1

1 changed file

StatusFile+-
M gartermctl/src/main.rs 26 2
gartermctl/src/main.rsmodified
@@ -36,6 +36,12 @@ enum Commands {
3636
         /// Working directory
3737
         #[arg(long)]
3838
         cwd: Option<String>,
39
+        /// Command to run after shell starts
40
+        #[arg(long, short = 'e')]
41
+        exec: Option<String>,
42
+        /// Tab title
43
+        #[arg(long, short = 't')]
44
+        title: Option<String>,
3945
     },
4046
     /// Close the current tab
4147
     CloseTab,
@@ -53,6 +59,17 @@ enum Commands {
5359
         /// Split horizontally (side-by-side)
5460
         #[arg(long, short = 'H')]
5561
         horizontal: bool,
62
+        /// Working directory
63
+        #[arg(long)]
64
+        cwd: Option<String>,
65
+        /// Command to run after shell starts
66
+        #[arg(long, short = 'e')]
67
+        exec: Option<String>,
68
+    },
69
+    /// Load a named session from config
70
+    LoadSession {
71
+        /// Session name
72
+        name: String,
5673
     },
5774
     /// Close the focused pane
5875
     ClosePane,
@@ -204,17 +221,24 @@ fn main() -> Result<()> {
204221
     // Convert command enum to IPC Command
205222
     let cmd = match &cli.command {
206223
         Commands::List => unreachable!(),
207
-        Commands::NewTab { cwd } => Command::NewTab { cwd: cwd.clone() },
224
+        Commands::NewTab { cwd, exec, title } => Command::NewTab {
225
+            cwd: cwd.clone(),
226
+            startup_cmd: exec.clone(),
227
+            title: title.clone(),
228
+        },
208229
         Commands::CloseTab => Command::CloseTab,
209230
         Commands::NextTab => Command::NextTab,
210231
         Commands::PrevTab => Command::PrevTab,
211232
         Commands::Tab { index } => Command::SwitchTab { index: *index },
212
-        Commands::Split { horizontal } => Command::Split {
233
+        Commands::Split { horizontal, cwd, exec } => Command::Split {
213234
             direction: if *horizontal { "horizontal".into() } else { "vertical".into() },
235
+            cwd: cwd.clone(),
236
+            startup_cmd: exec.clone(),
214237
         },
215238
         Commands::ClosePane => Command::ClosePane,
216239
         Commands::Focus { direction } => Command::FocusPaneDirection { direction: direction.clone() },
217240
         Commands::Send { text } => Command::SendText { text: text.clone() },
241
+        Commands::LoadSession { name } => Command::LoadSession { name: name.clone() },
218242
         Commands::Info => Command::GetInfo,
219243
         Commands::Reload => Command::Reload,
220244
         Commands::Quit => Command::Quit,