use std::path::PathBuf;
use clap::{Args, Parser, Subcommand};
use crate::domain::event::RecordStatus;
#[derive(Debug, Parser)]
#[command(name = "sillok", version, about)]
pub struct Cli {
#[arg(long, global = true, env = "SILLOK_STORE")]
pub store: Option<PathBuf>,
#[arg(long, global = true)]
pub human: bool,
#[arg(long, global = true)]
pub json: bool,
#[arg(long, global = true)]
pub at: Option<String>,
#[arg(long, global = true)]
pub tz: Option<String>,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Init,
Note(NoteArgs),
Objective(ObjectiveArgs),
Amend(AmendArgs),
Retract(RetractArgs),
Show(IdArgs),
Day(DayArgs),
Query(QueryArgs),
Tree(TreeArgs),
Doctor,
Export(ExportArgs),
Truncate(TruncateArgs),
}
impl Command {
pub fn name(&self) -> &'static str {
match self {
Self::Init => "init",
Self::Note(_) => "note",
Self::Objective(_) => "objective",
Self::Amend(_) => "amend",
Self::Retract(_) => "retract",
Self::Show(_) => "show",
Self::Day(_) => "day",
Self::Query(_) => "query",
Self::Tree(_) => "tree",
Self::Doctor => "doctor",
Self::Export(_) => "export",
Self::Truncate(_) => "truncate",
}
}
}
#[derive(Debug, Args)]
pub struct NoteArgs {
pub text: String,
#[arg(long)]
pub parent: Option<String>,
#[arg(long)]
pub purpose: Option<String>,
#[arg(long, value_delimiter = ',')]
pub tags: Vec<String>,
#[arg(long, value_enum, default_value_t = RecordStatus::Completed)]
pub status: RecordStatus,
}
#[derive(Debug, Args)]
pub struct ObjectiveArgs {
#[command(subcommand)]
pub command: ObjectiveCommand,
}
#[derive(Debug, Subcommand)]
pub enum ObjectiveCommand {
Add(ObjectiveAddArgs),
Complete(ObjectiveCompleteArgs),
}
#[derive(Debug, Args)]
pub struct ObjectiveAddArgs {
pub text: String,
#[arg(long, value_delimiter = ',')]
pub tags: Vec<String>,
}
#[derive(Debug, Args)]
pub struct ObjectiveCompleteArgs {
pub id: String,
#[arg(long)]
pub note: Option<String>,
}
#[derive(Debug, Args)]
pub struct AmendArgs {
pub id: String,
#[arg(long)]
pub text: Option<String>,
#[arg(long, value_enum)]
pub status: Option<RecordStatus>,
#[arg(long)]
pub purpose: Option<String>,
#[arg(long, value_delimiter = ',')]
pub tags: Vec<String>,
}
#[derive(Debug, Args)]
pub struct RetractArgs {
pub id: String,
#[arg(long)]
pub reason: String,
}
#[derive(Debug, Args)]
pub struct IdArgs {
pub id: String,
}
#[derive(Debug, Args)]
pub struct DayArgs {
#[arg(long)]
pub date: Option<String>,
}
#[derive(Debug, Args)]
pub struct QueryArgs {
#[arg(long)]
pub from: String,
#[arg(long)]
pub to: String,
#[arg(long)]
pub context: Option<String>,
#[arg(long)]
pub tag: Option<String>,
#[arg(long, value_enum)]
pub status: Option<RecordStatus>,
}
#[derive(Debug, Args)]
pub struct TreeArgs {
#[arg(long)]
pub date: Option<String>,
#[arg(long)]
pub root: Option<String>,
}
#[derive(Debug, Args)]
pub struct ExportArgs {
#[command(subcommand)]
pub command: ExportCommand,
}
#[derive(Debug, Subcommand)]
pub enum ExportCommand {
Json(ExportJsonArgs),
}
#[derive(Debug, Args)]
pub struct ExportJsonArgs {
#[arg(long)]
pub from: Option<String>,
#[arg(long)]
pub to: Option<String>,
}
#[derive(Debug, Args)]
pub struct TruncateArgs {
#[arg(long)]
pub yes: bool,
}