judo/cli/args.rs
1use clap::{Parser, Subcommand};
2
3#[derive(Parser, Debug)]
4#[command(version, about)]
5pub struct Cli {
6 #[command(subcommand)]
7 pub command: Option<Commands>,
8}
9
10#[derive(Subcommand, Debug)]
11pub enum Commands {
12 /// Manage databases
13 Dbs {
14 #[command(subcommand)]
15 command: Option<DbCommands>,
16 },
17
18 /// Manage todo lists
19 Lists {
20 #[command(subcommand)]
21 command: Option<ListCommands>,
22 },
23
24 /// Manage todo items
25 Items {
26 #[command(subcommand)]
27 command: Option<ItemCommands>,
28 },
29}
30
31#[derive(Subcommand, Debug)]
32pub enum DbCommands {
33 /// List all databases
34 Show,
35
36 /// Add a new database with the given name
37 Add {
38 /// Name of the new database
39 #[arg(short, long)]
40 name: String,
41 },
42}
43
44#[derive(Subcommand, Debug)]
45pub enum ListCommands {
46 /// List all todo lists in database(s).
47 Show {
48 /// Name of the new todo list
49 #[arg(short, long)]
50 name: Option<String>,
51 },
52
53 /// Add a new todo list with the given name to the specified database (default DB if omitted)
54 Add {
55 /// Name of the new todo list
56 #[arg(short, long)]
57 name: String,
58
59 /// Name of the database to add the new list to (default DB if omitted)
60 #[arg(short, long)]
61 db: Option<String>,
62 },
63
64 /// Delete an existing todo list with the given name or ID from the specified database (default DB if omitted)
65 Delete {
66 /// Name of the list to be deleted (do not use with -i|--id)
67 #[arg(short, long)]
68 name: Option<String>,
69
70 /// ID of the list to be deleted (do not use with -n|--name)
71 #[arg(short, long)]
72 id: Option<i64>,
73
74 /// Name of the database that contains the target list (default DB if omitted)
75 #[arg(short, long)]
76 db: Option<String>,
77 },
78}
79
80#[derive(Subcommand, Debug)]
81pub enum ItemCommands {
82 /// List all todo items in a table which shows what list and database each belongs to
83 Show,
84
85 /// Add a new todo item with the given name to the specified list (by ID or name) and database (default DB if omitted)
86 Add {
87 /// Name of the new todo item
88 #[arg(short, long)]
89 name: String,
90
91 /// Name of the database that contains the list to hold the new todo item (default DB if omitted)
92 #[arg(short, long)]
93 db: Option<String>,
94
95 /// Name of the list to hold the new todo item (do not use with -i|--id)
96 #[arg(short, long)]
97 list_name: Option<String>,
98
99 /// ID of the list to hold the new todo item (do not use with -n|--name)
100 #[arg(short = 'i', long)]
101 list_id: Option<i64>,
102 },
103
104 /// Delete an existing todo item with the given ID from the given database (default DB if omitted)
105 Delete {
106 /// ID of the target todo item
107 #[arg(short, long)]
108 id: i64,
109 /// Name of the database that contains the todo item to be deleted (default DB if omitted)
110 #[arg(short, long)]
111 db: Option<String>,
112 },
113
114 /// Toggle whether a todo item is marked as done or not
115 ToggleDone {
116 /// ID of the target item
117 #[arg(short, long)]
118 id: i64,
119
120 /// Name of the database containing the target item
121 #[arg(short, long)]
122 db: Option<String>,
123 },
124}