2 Commits

Author SHA1 Message Date
e484e279d9 chore: release v0.1.1 2026-03-01 11:07:42 +01:00
abffaa8ef9 feat: add bulk option to todo done 2026-03-01 11:07:07 +01:00
5 changed files with 27 additions and 14 deletions

2
Cargo.lock generated
View File

@@ -1537,7 +1537,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "todo" name = "todo"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "todo" name = "todo"
version = "0.1.0" version = "0.1.1"
edition = "2024" edition = "2024"
rust-version = "1.85" rust-version = "1.85"
description = "simple todo cli with mcp server for ai integration" description = "simple todo cli with mcp server for ai integration"

View File

@@ -86,8 +86,9 @@ pub struct ListArgs {
#[derive(Args)] #[derive(Args)]
pub struct DoneArgs { pub struct DoneArgs {
/// todo id /// todo id(s)
pub id: i64, #[arg(required = true)]
pub id: Vec<i64>,
} }
#[derive(Args)] #[derive(Args)]

View File

@@ -65,9 +65,11 @@ async fn list(ctx: &Ctx<'_>, args: ListArgs) -> Result<()> {
} }
async fn done(ctx: &Ctx<'_>, args: DoneArgs) -> Result<()> { async fn done(ctx: &Ctx<'_>, args: DoneArgs) -> Result<()> {
let todo = db::complete_todo(ctx.pool, args.id).await?; for id in args.id {
let todo = db::complete_todo(ctx.pool, id).await?;
print!("{} ", "done:".green().bold()); print!("{} ", "done:".green().bold());
print_todo(&todo); print_todo(&todo);
}
Ok(()) Ok(())
} }

View File

@@ -79,9 +79,9 @@ fn tool_schemas() -> Value {
"inputSchema": { "inputSchema": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "type": "integer" } "id": { "type": "integer", "description": "single todo id" },
}, "ids": { "type": "array", "items": { "type": "integer" }, "description": "multiple todo ids" }
"required": ["id"] }
} }
}, },
{ {
@@ -182,11 +182,21 @@ async fn dispatch(pool: &Pool, name: &str, args: &Value) -> Value {
.map(|t| serde_json::to_string(&t).unwrap()) .map(|t| serde_json::to_string(&t).unwrap())
} }
"todo_done" => { "todo_done" => {
let id = match args.get("id").and_then(|v| v.as_i64()) { let ids: Vec<i64> = if let Some(arr) = args.get("ids").and_then(|v| v.as_array()) {
Some(id) => id, arr.iter().filter_map(|v| v.as_i64()).collect()
None => return tool_error("missing required arg: id".into()), } 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" => { "todo_edit" => {
let id = match args.get("id").and_then(|v| v.as_i64()) { let id = match args.get("id").and_then(|v| v.as_i64()) {