()
| 236 | |
| 237 | #[tokio::main] |
| 238 | async fn main() -> Result<()> { |
| 239 | let cli = Cli::parse(); |
| 240 | |
| 241 | if cli.verbose { |
| 242 | tracing_subscriber::fmt() |
| 243 | .with_env_filter("ccql=debug") |
| 244 | .init(); |
| 245 | } |
| 246 | |
| 247 | let data_dir = cli |
| 248 | .data_dir |
| 249 | .or_else(|| std::env::var("CLAUDE_DATA_DIR").ok().map(PathBuf::from)) |
| 250 | .unwrap_or_else(Config::default_data_dir); |
| 251 | |
| 252 | let config = Config::new(data_dir)?; |
| 253 | |
| 254 | // Handle default SQL command when no subcommand is provided |
| 255 | if let Some(query) = cli.query { |
| 256 | if cli.command.is_none() { |
| 257 | return commands::sql(&config, &query, cli.write, cli.dry_run, cli.format).await; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | match cli.command { |
| 262 | Some(Commands::Sql { |
| 263 | query, |
| 264 | write, |
| 265 | dry_run, |
| 266 | }) => { |
| 267 | commands::sql(&config, &query, write, dry_run, cli.format).await?; |
| 268 | } |
| 269 | Some(Commands::Prompts { |
| 270 | session, |
| 271 | project, |
| 272 | since, |
| 273 | until, |
| 274 | limit, |
| 275 | }) => { |
| 276 | commands::prompts(&config, session, project, since, until, limit, cli.format).await?; |
| 277 | } |
| 278 | Some(Commands::Query { |
| 279 | query, |
| 280 | source, |
| 281 | file_pattern, |
| 282 | }) => { |
| 283 | commands::query(&config, &query, &source, file_pattern, cli.format).await?; |
| 284 | } |
| 285 | Some(Commands::Sessions { |
| 286 | detailed, |
| 287 | project, |
| 288 | sort_by, |
| 289 | }) => { |
| 290 | commands::sessions(&config, detailed, project, &sort_by, cli.format).await?; |
| 291 | } |
| 292 | Some(Commands::Stats { |
| 293 | group_by, |
| 294 | since, |
| 295 | until, |
nothing calls this directly
no test coverage detected