From c75ba9b21f96819de3fe9e7a09d79bd36fce4282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Sat, 28 Feb 2026 12:57:02 +0100 Subject: [PATCH] feat: add initial cli definition --- src/cli.rs | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 src/cli.rs diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..085e221 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,115 @@ +use clap::{Args, Parser, Subcommand}; + +use crate::model::Priority; + +#[derive(Parser)] +#[command(name = "todo", about = "global thought capture", version)] +pub struct Cli { + #[command(subcommand)] + pub command: Command, +} + +#[derive(Subcommand)] +pub enum Command { + /// add a new todo + #[command(alias = "a")] + Add(AddArgs), + + /// list todos + #[command(alias = "ls")] + List(ListArgs), + + /// mark a todo as done + Done(DoneArgs), + + /// edit a todo + Edit(EditArgs), + + /// remove a todo permanently + #[command(alias = "rm")] + Remove(RemoveArgs), + + /// list all tags in use + Tags, + + /// remove all completed todos + Purge, +} + +#[derive(Args)] +pub struct AddArgs { + /// the todo text + pub text: String, + + /// priority (critical/high/medium/low or c/h/m/l) + #[arg(short, long, default_value = "medium")] + pub priority: Priority, + + /// tags (repeatable: -t foo -t bar) + #[arg(short, long)] + pub tag: Vec, + + /// do not associate with current repo + #[arg(long)] + pub no_project: bool, +} + +#[derive(Args)] +pub struct ListArgs { + /// filter by tag + #[arg(short, long)] + pub tag: Vec, + + /// filter by priority + #[arg(short, long)] + pub priority: Option, + + /// search text (substring match) + #[arg(short, long)] + pub search: Option, + + /// include completed todos + #[arg(short = 'a', long)] + pub all: bool, + + /// only show todos for current repo + #[arg(long)] + pub here: bool, + + /// output as json + #[arg(long)] + pub json: bool, +} + +#[derive(Args)] +pub struct DoneArgs { + /// todo id + pub id: i64, +} + +#[derive(Args)] +pub struct EditArgs { + /// todo id + pub id: i64, + + /// new text + pub text: Option, + + /// new priority + #[arg(short, long)] + pub priority: Option, + + /// add tags + #[arg(short, long)] + pub tag: Vec, + + /// remove tags + #[arg(long)] + pub untag: Vec, +} + +#[derive(Args)] +pub struct RemoveArgs { + /// todo id + pub id: i64, +}