(&self, ctx: CommandContext)
| 46 | #[async_trait::async_trait] |
| 47 | impl CommandHandler for SqlHandler { |
| 48 | async fn run(&self, ctx: CommandContext) -> CommandResult { |
| 49 | let query = match ctx.args.get("query").and_then(|v| v.as_str()) { |
| 50 | Some(q) if !q.is_empty() => q.to_string(), |
| 51 | _ => { |
| 52 | return CommandResult::Error { |
| 53 | code: "MISSING_QUERY".to_string(), |
| 54 | message: "No SQL query provided. Run `devsql --help` for usage examples." |
| 55 | .to_string(), |
| 56 | retryable: false, |
| 57 | exit_code: Some(1), |
| 58 | cta: None, |
| 59 | }; |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | let repo_str = ctx |
| 64 | .options |
| 65 | .get("repo") |
| 66 | .and_then(|v| v.as_str()) |
| 67 | .unwrap_or("."); |
| 68 | |
| 69 | let repo_path = if repo_str == "." { |
| 70 | match std::env::current_dir() { |
| 71 | Ok(p) => p, |
| 72 | Err(e) => { |
| 73 | return CommandResult::Error { |
| 74 | code: "PATH_ERROR".to_string(), |
| 75 | message: format!("Cannot determine current directory: {e}"), |
| 76 | retryable: false, |
| 77 | exit_code: Some(1), |
| 78 | cta: None, |
| 79 | }; |
| 80 | } |
| 81 | } |
| 82 | } else { |
| 83 | PathBuf::from(repo_str) |
| 84 | }; |
| 85 | |
| 86 | let claude_dir = match ctx.options.get("data_dir").and_then(|v| v.as_str()) { |
| 87 | Some(d) => PathBuf::from(d), |
| 88 | None => dirs::home_dir() |
| 89 | .unwrap_or_else(|| PathBuf::from(".")) |
| 90 | .join(".claude"), |
| 91 | }; |
| 92 | |
| 93 | let mut engine = match UnifiedEngine::new(claude_dir, repo_path) { |
| 94 | Ok(e) => e, |
| 95 | Err(e) => { |
| 96 | return CommandResult::Error { |
| 97 | code: "ENGINE_ERROR".to_string(), |
| 98 | message: format!("Failed to create engine: {e}"), |
| 99 | retryable: false, |
| 100 | exit_code: Some(1), |
| 101 | cta: None, |
| 102 | }; |
| 103 | } |
| 104 | }; |
| 105 |
nothing calls this directly
no test coverage detected