Add --panel flag to new-split command (#10)

* Add --panel flag to new-split command

Allows splitting a specific panel without changing focus first.

Usage: cmuxterm new-split <direction> [--panel <id|index>]

Example: cmuxterm new-split down --panel 1

* Return new panel ID from new-split command

new-split now returns the UUID of the newly created panel, enabling
reliable chaining of split operations without index drift issues.

Before: OK
After:  OK F2675177-3838-49AF-A1A0-1744C0048E99

Example workflow to create left + 2x2 grid on right:
  RIGHT=$(cmuxterm new-split right | awk '{print $2}')
  BOTTOM=$(cmuxterm new-split down --panel $RIGHT | awk '{print $2}')
  cmuxterm new-split right --panel $RIGHT
  cmuxterm new-split right --panel $BOTTOM
This commit is contained in:
Lawrence Chen 2026-02-03 21:37:49 -08:00 committed by GitHub
parent 7bae1216ff
commit 600683cd7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 16 deletions

View file

@ -192,10 +192,12 @@ struct CMUXCLI {
print(response)
case "new-split":
guard let direction = commandArgs.first else {
let (panelArg, remaining) = parseOption(commandArgs, name: "--panel")
guard let direction = remaining.first else {
throw CLIError(message: "new-split requires a direction")
}
let response = try client.send(command: "new_split \(direction)")
let cmd = panelArg != nil ? "new_split \(direction) \(panelArg!)" : "new_split \(direction)"
let response = try client.send(command: cmd)
print(response)
case "list-panels":
@ -509,7 +511,7 @@ struct CMUXCLI {
ping
list-tabs
new-tab
new-split <left|right|up|down>
new-split <left|right|up|down> [--panel <id|index>]
list-panels [--tab <id|index>]
focus-panel --panel <id|index>
close-tab --tab <id|index>