From 1c606d4ff3df7ea7d641e6ad13bc30caf8082eaa Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sat, 4 Jul 2026 16:30:09 +0300 Subject: [PATCH] refactor: route cli pane placement through runtime adapters --- src/cli/pane.rs | 48 +++++++++++----------------------------------- src/cli/runtime.rs | 40 +++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/src/cli/pane.rs b/src/cli/pane.rs index b2579d42..a178eb4b 100644 --- a/src/cli/pane.rs +++ b/src/cli/pane.rs @@ -206,10 +206,7 @@ fn pane_focus(args: &[String]) -> std::io::Result { } }; - 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 { @@ -221,10 +218,7 @@ fn pane_resize(args: &[String]) -> std::io::Result { } }; - 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, String> { @@ -364,10 +358,7 @@ fn pane_zoom(args: &[String]) -> std::io::Result { } }; - 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 { @@ -442,13 +433,10 @@ fn pane_rename(args: &[String]) -> std::io::Result { 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 { @@ -540,10 +528,7 @@ fn pane_split(args: &[String]) -> std::io::Result { } }; - 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 { } }; - 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 { @@ -668,10 +650,7 @@ fn pane_move(args: &[String]) -> std::io::Result { } }; - 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 { @@ -922,12 +901,7 @@ fn pane_close(args: &[String]) -> std::io::Result { 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 { diff --git a/src/cli/runtime.rs b/src/cli/runtime.rs index 0f6fccd1..0d1251b1 100644 --- a/src/cli/runtime.rs +++ b/src/cli/runtime.rs @@ -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 { @@ -86,3 +88,35 @@ pub(super) fn worktree_open(params: WorktreeOpenParams) -> std::io::Result pub(super) fn worktree_remove(params: WorktreeRemoveParams) -> std::io::Result { print_method_response("cli:worktree:remove", Method::WorktreeRemove(params)) } + +pub(super) fn pane_focus(params: PaneFocusDirectionParams) -> std::io::Result { + print_method_response("cli:pane:focus", Method::PaneFocusDirection(params)) +} + +pub(super) fn pane_resize(params: PaneResizeParams) -> std::io::Result { + print_method_response("cli:pane:resize", Method::PaneResize(params)) +} + +pub(super) fn pane_zoom(params: PaneZoomParams) -> std::io::Result { + print_method_response("cli:pane:zoom", Method::PaneZoom(params)) +} + +pub(super) fn pane_rename(params: PaneRenameParams) -> std::io::Result { + print_method_response("cli:pane:rename", Method::PaneRename(params)) +} + +pub(super) fn pane_split(params: PaneSplitParams) -> std::io::Result { + print_method_response("cli:pane:split", Method::PaneSplit(params)) +} + +pub(super) fn pane_swap(params: PaneSwapParams) -> std::io::Result { + print_method_response("cli:pane:swap", Method::PaneSwap(params)) +} + +pub(super) fn pane_move(params: PaneMoveParams) -> std::io::Result { + print_method_response("cli:pane:move", Method::PaneMove(params)) +} + +pub(super) fn pane_close(pane_id: String) -> std::io::Result { + print_method_response("cli:pane:close", Method::PaneClose(PaneTarget { pane_id })) +}