feat: add initial cli definition
This commit is contained in:
115
src/cli.rs
Normal file
115
src/cli.rs
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user