feat: add initial cli definition

This commit is contained in:
2026-02-28 12:57:02 +01:00
parent 7ef93a30f5
commit c75ba9b21f

115
src/cli.rs Normal file
View File

@@ -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<String>,
/// 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<String>,
/// filter by priority
#[arg(short, long)]
pub priority: Option<Priority>,
/// search text (substring match)
#[arg(short, long)]
pub search: Option<String>,
/// 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<String>,
/// new priority
#[arg(short, long)]
pub priority: Option<Priority>,
/// add tags
#[arg(short, long)]
pub tag: Vec<String>,
/// remove tags
#[arg(long)]
pub untag: Vec<String>,
}
#[derive(Args)]
pub struct RemoveArgs {
/// todo id
pub id: i64,
}