codebridge_cli/actions/
mod.rs1use crate::config::AppConfig;
2use crate::error::AppResult;
3use crate::models::{Action, ActionResult};
4use std::path::Path;
5
6mod create_directory;
7mod delete_file;
8mod git;
9mod git_worktree;
10mod list_directory;
11mod read_file;
12mod run_script;
13mod write_file;
14
15pub async fn execute_action(
16 action: Action,
17 project_root: &Path,
18 config: &AppConfig,
19) -> AppResult<ActionResult> {
20 match action {
21 Action::ReadFile(params) => Ok(read_file::handle(params, project_root, config).await),
22 Action::WriteFile(params) => Ok(write_file::handle(params, project_root, config).await),
23 Action::DeleteFile(params) => Ok(delete_file::handle(params, project_root, config).await),
24 Action::CreateDirectory(params) => {
25 Ok(create_directory::handle(params, project_root, config).await)
26 }
27 Action::ListDirectory(params) => {
28 Ok(list_directory::handle(params, project_root, config).await)
29 }
30 Action::GitStatus => Ok(git::handle_status(project_root, config).await),
31 Action::GitAdd(params) => Ok(git::handle_add(params, project_root, config).await),
32 Action::GitCommit(params) => Ok(git::handle_commit(params, project_root, config).await),
33 Action::GitPush(params) => Ok(git::handle_push(params, project_root, config).await),
34 Action::GitDiff(params) => Ok(git::handle_diff(params, project_root, config).await),
35 Action::GitInit => Ok(git::handle_init(project_root, config).await),
36 Action::RunScript(params) => Ok(run_script::handle(params, project_root, config).await),
37 Action::GitWorktreeAdd(params) => {
39 git_worktree::handle_add(params, project_root, config).await
40 }
41 Action::GitWorktreeList => git_worktree::handle_list(project_root, config).await,
42 Action::GitWorktreeRemove(params) => {
43 git_worktree::handle_remove(params, project_root, config).await
44 }
45 Action::GitWorktreeMerge(params) => {
46 git_worktree::handle_merge(params, project_root, config).await
47 }
48 }
49}