(&self, ctx: CommandContext)
| 43 | #[async_trait::async_trait] |
| 44 | impl CommandHandler for SearchHandler { |
| 45 | async fn run(&self, ctx: CommandContext) -> CommandResult { |
| 46 | let query = match ctx.args.get("query").and_then(|v| v.as_str()) { |
| 47 | Some(q) => q.to_string(), |
| 48 | None => { |
| 49 | return CommandResult::Error { |
| 50 | code: "MISSING_ARG".into(), |
| 51 | message: "Missing required argument: query".into(), |
| 52 | retryable: false, |
| 53 | exit_code: Some(1), |
| 54 | cta: None, |
| 55 | }; |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | let kind = ctx |
| 60 | .options |
| 61 | .get("kind") |
| 62 | .and_then(|v| v.as_str()) |
| 63 | .map(|s| s.to_string()); |
| 64 | let limit = ctx |
| 65 | .options |
| 66 | .get("limit") |
| 67 | .and_then(|v| v.as_i64()) |
| 68 | .unwrap_or(50); |
| 69 | |
| 70 | let (mut engine, _repo_path) = match engine_from_options(&ctx.options) { |
| 71 | Ok(v) => v, |
| 72 | Err(e) => return e, |
| 73 | }; |
| 74 | |
| 75 | // Load the symbols table |
| 76 | if let Err(e) = engine.load_code_tables(&["symbols"]) { |
| 77 | return CommandResult::Error { |
| 78 | code: "LOAD_ERROR".into(), |
| 79 | message: format!("Failed to load symbols table: {e}"), |
| 80 | retryable: false, |
| 81 | exit_code: Some(1), |
| 82 | cta: None, |
| 83 | }; |
| 84 | } |
| 85 | |
| 86 | // Build SQL query |
| 87 | let sql = if let Some(ref k) = kind { |
| 88 | format!( |
| 89 | "SELECT file_path, name, kind, line_start, signature \ |
| 90 | FROM symbols \ |
| 91 | WHERE name LIKE '%{query}%' AND kind = '{k}' \ |
| 92 | LIMIT {limit}" |
| 93 | ) |
| 94 | } else { |
| 95 | format!( |
| 96 | "SELECT file_path, name, kind, line_start, signature \ |
| 97 | FROM symbols \ |
| 98 | WHERE name LIKE '%{query}%' \ |
| 99 | LIMIT {limit}" |
| 100 | ) |
| 101 | }; |
| 102 |
nothing calls this directly
no test coverage detected