1use clap::{Parser, Subcommand};
2use crate::constants;
3
4#[derive(Parser, Debug)]
6#[command(name = "j", version = constants::VERSION, about = "快捷命令行工具", long_about = None)]
7#[command(disable_help_subcommand = true)]
8pub struct Cli {
9 #[command(subcommand)]
10 pub command: Option<SubCmd>,
11
12 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
14 pub args: Vec<String>,
15}
16
17#[derive(Subcommand, Debug)]
18pub enum SubCmd {
19 #[command(alias = "s")]
22 Set {
23 alias: String,
25 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
27 path: Vec<String>,
28 },
29
30 #[command(alias = "rm")]
32 Remove {
33 alias: String,
35 },
36
37 #[command(alias = "rn")]
39 Rename {
40 alias: String,
42 new_alias: String,
44 },
45
46 #[command(alias = "mf")]
48 Modify {
49 alias: String,
51 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
53 path: Vec<String>,
54 },
55
56 #[command(alias = "nt")]
59 Note {
60 alias: String,
62 category: String,
64 },
65
66 #[command(alias = "dnt")]
68 Denote {
69 alias: String,
71 category: String,
73 },
74
75 #[command(alias = "ls")]
78 List {
79 part: Option<String>,
81 },
82
83 #[command(alias = "find")]
85 Contain {
86 alias: String,
88 containers: Option<String>,
90 },
91
92 #[command(aliases = ["r"])]
95 Report {
96 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
98 content: Vec<String>,
99 },
100
101 #[command(name = "reportctl", alias = "rctl")]
103 Reportctl {
104 action: String,
106 arg: Option<String>,
108 },
109
110 #[command(alias = "c")]
112 Check {
113 line_count: Option<String>,
115 },
116
117 #[command(aliases = ["select", "look", "sch"])]
119 Search {
120 line_count: String,
122 target: String,
124 #[arg(allow_hyphen_values = true)]
126 fuzzy: Option<String>,
127 },
128
129 Concat {
132 name: String,
134 #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
136 content: Vec<String>,
137 },
138
139 Time {
142 function: String,
144 arg: String,
146 },
147
148 Log {
151 key: String,
153 value: String,
155 },
156
157 #[command(alias = "chg")]
159 Change {
160 part: String,
162 field: String,
164 value: String,
166 },
167
168 #[command(alias = "cls")]
170 Clear,
171
172 #[command(alias = "v")]
175 Version,
176
177 #[command(alias = "h")]
179 Help,
180
181 #[command(aliases = ["q", "quit"])]
183 Exit,
184
185 Completion {
187 shell: Option<String>,
189 },
190}