refactor: route cli pane placement through runtime adapters

This commit is contained in:
Ogulcan Celik 2026-07-04 16:30:09 +03:00
parent ce6c0dc842
commit 1c606d4ff3
2 changed files with 48 additions and 40 deletions

View File

@ -206,10 +206,7 @@ fn pane_focus(args: &[String]) -> std::io::Result<i32> {
}
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:focus".into(),
method: Method::PaneFocusDirection(params),
})?)
super::runtime::pane_focus(params)
}
fn pane_resize(args: &[String]) -> std::io::Result<i32> {
@ -221,10 +218,7 @@ fn pane_resize(args: &[String]) -> std::io::Result<i32> {
}
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:resize".into(),
method: Method::PaneResize(params),
})?)
super::runtime::pane_resize(params)
}
fn parse_optional_current_pane_args(args: &[String]) -> Result<Option<String>, String> {
@ -364,10 +358,7 @@ fn pane_zoom(args: &[String]) -> std::io::Result<i32> {
}
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:zoom".into(),
method: Method::PaneZoom(params),
})?)
super::runtime::pane_zoom(params)
}
fn parse_pane_zoom_args(args: &[String]) -> Result<PaneZoomParams, String> {
@ -442,13 +433,10 @@ fn pane_rename(args: &[String]) -> std::io::Result<i32> {
Some(args[1..].join(" "))
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:rename".into(),
method: Method::PaneRename(PaneRenameParams {
pane_id: super::normalize_pane_id(raw_pane_id),
label,
}),
})?)
super::runtime::pane_rename(PaneRenameParams {
pane_id: super::normalize_pane_id(raw_pane_id),
label,
})
}
fn pane_read(args: &[String]) -> std::io::Result<i32> {
@ -540,10 +528,7 @@ fn pane_split(args: &[String]) -> std::io::Result<i32> {
}
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:split".into(),
method: Method::PaneSplit(params),
})?)
super::runtime::pane_split(params)
}
fn parse_pane_split_args(
@ -653,10 +638,7 @@ fn pane_swap(args: &[String]) -> std::io::Result<i32> {
}
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:swap".into(),
method: Method::PaneSwap(params),
})?)
super::runtime::pane_swap(params)
}
fn pane_move(args: &[String]) -> std::io::Result<i32> {
@ -668,10 +650,7 @@ fn pane_move(args: &[String]) -> std::io::Result<i32> {
}
};
super::print_response(&super::send_request(&Request {
id: "cli:pane:move".into(),
method: Method::PaneMove(params),
})?)
super::runtime::pane_move(params)
}
fn parse_pane_move_args(args: &[String]) -> Result<PaneMoveParams, String> {
@ -922,12 +901,7 @@ fn pane_close(args: &[String]) -> std::io::Result<i32> {
return Ok(2);
}
super::print_response(&super::send_request(&Request {
id: "cli:pane:close".into(),
method: Method::PaneClose(PaneTarget {
pane_id: super::normalize_pane_id(raw_pane_id),
}),
})?)
super::runtime::pane_close(super::normalize_pane_id(raw_pane_id))
}
fn pane_send_text(args: &[String]) -> std::io::Result<i32> {

View File

@ -1,7 +1,9 @@
use crate::api::schema::{
EmptyParams, Method, Request, TabCreateParams, TabListParams, TabRenameParams, TabTarget,
WorkspaceCreateParams, WorkspaceRenameParams, WorkspaceTarget, WorktreeCreateParams,
WorktreeListParams, WorktreeOpenParams, WorktreeRemoveParams,
EmptyParams, Method, PaneFocusDirectionParams, PaneMoveParams, PaneRenameParams,
PaneResizeParams, PaneSplitParams, PaneSwapParams, PaneTarget, PaneZoomParams, Request,
TabCreateParams, TabListParams, TabRenameParams, TabTarget, WorkspaceCreateParams,
WorkspaceRenameParams, WorkspaceTarget, WorktreeCreateParams, WorktreeListParams,
WorktreeOpenParams, WorktreeRemoveParams,
};
fn print_method_response(id: &'static str, method: Method) -> std::io::Result<i32> {
@ -86,3 +88,35 @@ pub(super) fn worktree_open(params: WorktreeOpenParams) -> std::io::Result<i32>
pub(super) fn worktree_remove(params: WorktreeRemoveParams) -> std::io::Result<i32> {
print_method_response("cli:worktree:remove", Method::WorktreeRemove(params))
}
pub(super) fn pane_focus(params: PaneFocusDirectionParams) -> std::io::Result<i32> {
print_method_response("cli:pane:focus", Method::PaneFocusDirection(params))
}
pub(super) fn pane_resize(params: PaneResizeParams) -> std::io::Result<i32> {
print_method_response("cli:pane:resize", Method::PaneResize(params))
}
pub(super) fn pane_zoom(params: PaneZoomParams) -> std::io::Result<i32> {
print_method_response("cli:pane:zoom", Method::PaneZoom(params))
}
pub(super) fn pane_rename(params: PaneRenameParams) -> std::io::Result<i32> {
print_method_response("cli:pane:rename", Method::PaneRename(params))
}
pub(super) fn pane_split(params: PaneSplitParams) -> std::io::Result<i32> {
print_method_response("cli:pane:split", Method::PaneSplit(params))
}
pub(super) fn pane_swap(params: PaneSwapParams) -> std::io::Result<i32> {
print_method_response("cli:pane:swap", Method::PaneSwap(params))
}
pub(super) fn pane_move(params: PaneMoveParams) -> std::io::Result<i32> {
print_method_response("cli:pane:move", Method::PaneMove(params))
}
pub(super) fn pane_close(pane_id: String) -> std::io::Result<i32> {
print_method_response("cli:pane:close", Method::PaneClose(PaneTarget { pane_id }))
}