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

Function todos

crates/ccql/src/cli/commands.rs:417–482  ·  view source on GitHub ↗
(
    config: &Config,
    status: Option<TodoStatus>,
    agent: Option<String>,
    format: OutputFormat,
)

Source from the content-addressed store, hash-verified

415}
416
417pub async fn todos(
418 config: &Config,
419 status: Option<TodoStatus>,
420 agent: Option<String>,
421 format: OutputFormat,
422) -> Result<()> {
423 let ds = TodoDataSource::new(config.clone());
424 let mut files = ds.load_all().await?;
425
426 if let Some(ref agent_filter) = agent {
427 files.retain(|f| f.agent_id.contains(agent_filter));
428 }
429
430 let mut writer = OutputWriter::new(std::io::stdout(), format);
431
432 match format {
433 OutputFormat::Json => {
434 let data: Vec<_> = files
435 .iter()
436 .map(|f| {
437 serde_json::json!({
438 "workspace_id": f.workspace_id,
439 "agent_id": f.agent_id,
440 "todos": f.todos
441 })
442 })
443 .collect();
444 writer.write_json(&data)?;
445 }
446 OutputFormat::Raw | OutputFormat::Jsonl => {
447 for file in &files {
448 writer.write_json(&serde_json::json!({
449 "workspace_id": file.workspace_id,
450 "agent_id": file.agent_id,
451 "todos": file.todos
452 }))?;
453 }
454 }
455 OutputFormat::Table => {
456 let mut table = create_table();
457 table.set_header(vec!["Agent", "Status", "Task"]);
458
459 let mut total = 0;
460 for file in &files {
461 for todo in &file.todos {
462 if let Some(ref status_filter) = status {
463 if &todo.status != status_filter {
464 continue;
465 }
466 }
467 total += 1;
468 table.add_row(vec![
469 Cell::new(truncate_string(&file.agent_id, 12)),
470 Cell::new(todo.status.to_string()),
471 Cell::new(truncate_string(&todo.content, 60)),
472 ]);
473 }
474 }

Callers 1

mainFunction · 0.85

Calls 5

create_tableFunction · 0.85
write_jsonMethod · 0.80
write_tableMethod · 0.80
writelnMethod · 0.80
load_allMethod · 0.45

Tested by

no test coverage detected