aboutsummaryrefslogtreecommitdiff
path: root/src/cli/runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/runtime.rs')
-rw-r--r--src/cli/runtime.rs88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/cli/runtime.rs b/src/cli/runtime.rs
new file mode 100644
index 00000000..0f6fccd1
--- /dev/null
+++ b/src/cli/runtime.rs
@@ -0,0 +1,88 @@
+use crate::api::schema::{
+ EmptyParams, Method, 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> {
+ super::print_response(&super::send_request(&Request {
+ id: id.into(),
+ method,
+ })?)
+}
+
+pub(super) fn workspace_list() -> std::io::Result<i32> {
+ print_method_response(
+ "cli:workspace:list",
+ Method::WorkspaceList(EmptyParams::default()),
+ )
+}
+
+pub(super) fn workspace_create(params: WorkspaceCreateParams) -> std::io::Result<i32> {
+ print_method_response("cli:workspace:create", Method::WorkspaceCreate(params))
+}
+
+pub(super) fn workspace_get(workspace_id: String) -> std::io::Result<i32> {
+ print_method_response(
+ "cli:workspace:get",
+ Method::WorkspaceGet(WorkspaceTarget { workspace_id }),
+ )
+}
+
+pub(super) fn workspace_focus(workspace_id: String) -> std::io::Result<i32> {
+ print_method_response(
+ "cli:workspace:focus",
+ Method::WorkspaceFocus(WorkspaceTarget { workspace_id }),
+ )
+}
+
+pub(super) fn workspace_rename(params: WorkspaceRenameParams) -> std::io::Result<i32> {
+ print_method_response("cli:workspace:rename", Method::WorkspaceRename(params))
+}
+
+pub(super) fn workspace_close(workspace_id: String) -> std::io::Result<i32> {
+ print_method_response(
+ "cli:workspace:close",
+ Method::WorkspaceClose(WorkspaceTarget { workspace_id }),
+ )
+}
+
+pub(super) fn tab_list(params: TabListParams) -> std::io::Result<i32> {
+ print_method_response("cli:tab:list", Method::TabList(params))
+}
+
+pub(super) fn tab_create(params: TabCreateParams) -> std::io::Result<i32> {
+ print_method_response("cli:tab:create", Method::TabCreate(params))
+}
+
+pub(super) fn tab_get(tab_id: String) -> std::io::Result<i32> {
+ print_method_response("cli:tab:get", Method::TabGet(TabTarget { tab_id }))
+}
+
+pub(super) fn tab_focus(tab_id: String) -> std::io::Result<i32> {
+ print_method_response("cli:tab:focus", Method::TabFocus(TabTarget { tab_id }))
+}
+
+pub(super) fn tab_rename(params: TabRenameParams) -> std::io::Result<i32> {
+ print_method_response("cli:tab:rename", Method::TabRename(params))
+}
+
+pub(super) fn tab_close(tab_id: String) -> std::io::Result<i32> {
+ print_method_response("cli:tab:close", Method::TabClose(TabTarget { tab_id }))
+}
+
+pub(super) fn worktree_list(params: WorktreeListParams) -> std::io::Result<i32> {
+ print_method_response("cli:worktree:list", Method::WorktreeList(params))
+}
+
+pub(super) fn worktree_create(params: WorktreeCreateParams) -> std::io::Result<i32> {
+ print_method_response("cli:worktree:create", Method::WorktreeCreate(params))
+}
+
+pub(super) fn worktree_open(params: WorktreeOpenParams) -> std::io::Result<i32> {
+ print_method_response("cli:worktree:open", Method::WorktreeOpen(params))
+}
+
+pub(super) fn worktree_remove(params: WorktreeRemoveParams) -> std::io::Result<i32> {
+ print_method_response("cli:worktree:remove", Method::WorktreeRemove(params))
+}