MCPcopy Create free account
hub / github.com/douglance/devsql / run

Method run

crates/devsql/src/main.rs:48–152  ·  view source on GitHub ↗
(&self, ctx: CommandContext)

Source from the content-addressed store, hash-verified

46#[async_trait::async_trait]
47impl 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

Callers

nothing calls this directly

Calls 6

detect_tablesFunction · 0.85
is_emptyMethod · 0.80
load_claude_tablesMethod · 0.80
load_git_tablesMethod · 0.80
load_code_tablesMethod · 0.80
queryMethod · 0.80

Tested by

no test coverage detected