diff --git a/src/cli.rs b/src/cli.rs index 9962ec3..bd38c77 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -86,8 +86,9 @@ pub struct ListArgs { #[derive(Args)] pub struct DoneArgs { - /// todo id - pub id: i64, + /// todo id(s) + #[arg(required = true)] + pub id: Vec, } #[derive(Args)] diff --git a/src/commands.rs b/src/commands.rs index 18906ac..b426fdd 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -65,9 +65,11 @@ async fn list(ctx: &Ctx<'_>, args: ListArgs) -> Result<()> { } async fn done(ctx: &Ctx<'_>, args: DoneArgs) -> Result<()> { - let todo = db::complete_todo(ctx.pool, args.id).await?; - print!("{} ", "done:".green().bold()); - print_todo(&todo); + for id in args.id { + let todo = db::complete_todo(ctx.pool, id).await?; + print!("{} ", "done:".green().bold()); + print_todo(&todo); + } Ok(()) } diff --git a/src/mcp.rs b/src/mcp.rs index f69e5d5..bcbe04a 100644 --- a/src/mcp.rs +++ b/src/mcp.rs @@ -79,9 +79,9 @@ fn tool_schemas() -> Value { "inputSchema": { "type": "object", "properties": { - "id": { "type": "integer" } - }, - "required": ["id"] + "id": { "type": "integer", "description": "single todo id" }, + "ids": { "type": "array", "items": { "type": "integer" }, "description": "multiple todo ids" } + } } }, { @@ -182,11 +182,21 @@ async fn dispatch(pool: &Pool, name: &str, args: &Value) -> Value { .map(|t| serde_json::to_string(&t).unwrap()) } "todo_done" => { - let id = match args.get("id").and_then(|v| v.as_i64()) { - Some(id) => id, - None => return tool_error("missing required arg: id".into()), + let ids: Vec = if let Some(arr) = args.get("ids").and_then(|v| v.as_array()) { + arr.iter().filter_map(|v| v.as_i64()).collect() + } else if let Some(id) = args.get("id").and_then(|v| v.as_i64()) { + vec![id] + } else { + return tool_error("missing required arg: id or ids".into()); }; - db::complete_todo(pool, id).await.map(|t| serde_json::to_string(&t).unwrap()) + let mut todos = Vec::new(); + for id in ids { + match db::complete_todo(pool, id).await { + Ok(t) => todos.push(t), + Err(e) => return tool_error(e.to_string()), + } + } + Ok(serde_json::to_string(&todos).unwrap()) } "todo_edit" => { let id = match args.get("id").and_then(|v| v.as_i64()) {