1use std::path::PathBuf;
2
3use clap::{ArgAction, Parser, ValueEnum};
4
5#[derive(Debug, Clone, Parser)]
7#[command(
8 name = "f00",
9 version,
10 about = "List directory contents with a friendly default UI",
11 long_about = None,
12 disable_help_flag = true
14)]
15pub struct Args {
16 pub paths: Vec<PathBuf>,
18
19 #[arg(long = "help", action = ArgAction::Help, help = "Print help")]
21 pub help: Option<bool>,
22
23 #[arg(short = 'a', long = "all")]
25 pub all: bool,
26
27 #[arg(short = 'A', long = "almost-all")]
29 pub almost_all: bool,
30
31 #[arg(short = 'l')]
33 pub long: bool,
34
35 #[arg(short = '1')]
37 pub one_per_line: bool,
38
39 #[arg(short = 'C')]
41 pub columns: bool,
42
43 #[arg(short = 'm')]
45 pub commas: bool,
46
47 #[arg(short = 'h', long = "human-readable")]
49 pub human_readable: bool,
50
51 #[arg(long = "si")]
53 pub si: bool,
54
55 #[arg(short = 'R', long = "recursive")]
57 pub recursive: bool,
58
59 #[arg(short = 'r', long = "reverse")]
61 pub reverse: bool,
62
63 #[arg(short = 't')]
65 pub sort_time: bool,
66
67 #[arg(short = 'S')]
69 pub sort_size: bool,
70
71 #[arg(short = 'X')]
73 pub sort_extension: bool,
74
75 #[arg(short = 'v')]
77 pub sort_version: bool,
78
79 #[arg(short = 'U')]
81 pub sort_none: bool,
82
83 #[arg(long = "sort", value_name = "WORD")]
85 pub sort: Option<String>,
86
87 #[arg(long = "time", value_name = "WORD")]
89 pub time: Option<String>,
90
91 #[arg(short = 'u')]
93 pub access_time: bool,
94
95 #[arg(short = 'c')]
97 pub change_time: bool,
98
99 #[arg(
101 long = "color",
102 value_name = "WHEN",
103 default_value = "auto",
104 num_args = 0..=1,
105 default_missing_value = "always",
106 require_equals = true
107 )]
108 pub color: ColorArg,
109
110 #[arg(short = 'j', long = "json")]
112 pub json: bool,
113
114 #[arg(long = "csv")]
116 pub csv: bool,
117
118 #[arg(long = "tsv")]
120 pub tsv: bool,
121
122 #[arg(long = "tree")]
124 pub tree: bool,
125
126 #[arg(long = "gnu")]
128 pub gnu: bool,
129
130 #[arg(
132 long = "icons",
133 value_name = "WHEN",
134 default_value = "auto",
135 num_args = 0..=1,
136 default_missing_value = "always",
137 require_equals = true
138 )]
139 pub icons: IconsArg,
140
141 #[arg(short = 'F', long = "classify")]
143 pub classify: bool,
144
145 #[arg(short = 'p')]
147 pub indicator_slash: bool,
148
149 #[arg(long = "file-type")]
151 pub file_type: bool,
152
153 #[arg(long = "indicator-style", value_name = "WORD")]
155 pub indicator_style: Option<String>,
156
157 #[arg(long = "group-directories-first", alias = "dirs-first")]
159 pub dirs_first: bool,
160
161 #[arg(short = 'd', long = "directory")]
163 pub directory: bool,
164
165 #[arg(short = 'B', long = "ignore-backups")]
167 pub ignore_backups: bool,
168
169 #[arg(short = 'I', long = "ignore", value_name = "PATTERN", action = ArgAction::Append)]
171 pub ignore: Vec<String>,
172
173 #[arg(long = "hide", value_name = "PATTERN", action = ArgAction::Append)]
175 pub hide: Vec<String>,
176
177 #[arg(short = 'L', long = "dereference")]
179 pub dereference: bool,
180
181 #[arg(short = 'H', long = "dereference-command-line")]
183 pub dereference_command_line: bool,
184
185 #[arg(long = "dereference-command-line-symlink-to-dir")]
187 pub dereference_command_line_symlink_to_dir: bool,
188
189 #[arg(short = 'g')]
191 pub no_owner: bool,
192
193 #[arg(short = 'o')]
195 pub no_group_long: bool,
196
197 #[arg(short = 'G', long = "no-group")]
199 pub no_group: bool,
200
201 #[arg(short = 'n', long = "numeric-uid-gid")]
203 pub numeric_uid_gid: bool,
204
205 #[arg(short = 'i', long = "inode")]
207 pub inode: bool,
208
209 #[arg(short = 's', long = "size")]
211 pub size_blocks: bool,
212
213 #[arg(short = 'k', long = "kibibytes")]
215 pub kibibytes: bool,
216
217 #[arg(long = "block-size", value_name = "SIZE")]
219 pub block_size: Option<String>,
220
221 #[arg(long = "full-time")]
223 pub full_time: bool,
224
225 #[arg(long = "time-style", value_name = "TIME_STYLE")]
227 pub time_style: Option<String>,
228
229 #[arg(short = 'q', long = "hide-control-chars")]
231 pub hide_control_chars: bool,
232
233 #[arg(long = "show-control-chars")]
235 pub show_control_chars: bool,
236
237 #[arg(short = 'b', long = "escape")]
239 pub escape: bool,
240
241 #[arg(short = 'Q', long = "quote-name")]
243 pub quote_name: bool,
244
245 #[arg(short = 'N', long = "literal")]
247 pub literal: bool,
248
249 #[arg(long = "quoting-style", value_name = "WORD")]
251 pub quoting_style: Option<String>,
252
253 #[arg(short = 'x')]
255 pub across: bool,
256
257 #[arg(short = 'f')]
259 pub unsorted_all: bool,
260
261 #[arg(long = "format", value_name = "WORD")]
263 pub format: Option<String>,
264
265 #[arg(short = 'T', long = "tabsize", value_name = "COLS")]
267 pub tabsize: Option<usize>,
268
269 #[arg(short = 'w', long = "width", value_name = "COLS")]
271 pub width: Option<usize>,
272
273 #[arg(short = 'Z', long = "context")]
275 pub context: bool,
276
277 #[arg(long = "zero")]
279 pub zero: bool,
280
281 #[arg(short = 'D', long = "dired")]
283 pub dired: bool,
284
285 #[arg(long = "author")]
287 pub author: bool,
288
289 #[arg(
291 long = "hyperlink",
292 value_name = "WHEN",
293 num_args = 0..=1,
294 default_missing_value = "always",
295 require_equals = true
296 )]
297 pub hyperlink: Option<String>,
298
299 #[arg(long = "max-depth", value_name = "N")]
301 pub max_depth: Option<usize>,
302
303 #[arg(long = "git", default_value_t = true, action = clap::ArgAction::Set)]
305 pub git: bool,
306
307 #[arg(long = "config", value_name = "PATH")]
309 pub config: Option<PathBuf>,
310
311 #[arg(long = "browse", visible_alias = "tui")]
313 pub browse: bool,
314
315 #[arg(long = "ignore-files")]
317 pub ignore_files: bool,
318
319 #[arg(long = "no-ignore")]
321 pub no_ignore: bool,
322
323 #[arg(long = "archive", default_value_t = true, action = clap::ArgAction::Set)]
325 pub archive: bool,
326
327 #[arg(long = "threads", value_name = "N", default_value_t = 0)]
329 pub threads: usize,
330
331 #[arg(long = "profile")]
333 pub profile: bool,
334
335 #[arg(long = "io-uring", action = ArgAction::Set, default_value_t = true)]
337 pub io_uring: bool,
338
339 #[arg(long = "generate-completions", value_name = "SHELL", hide = true)]
341 pub generate_completions: Option<clap_complete::Shell>,
342
343 #[arg(long = "generate-man", hide = true, action = ArgAction::SetTrue)]
345 pub generate_man: bool,
346
347 #[arg(long = "update", action = ArgAction::SetTrue)]
349 pub update: bool,
350
351 #[arg(long = "check-update", action = ArgAction::SetTrue)]
353 pub check_update: bool,
354
355 #[arg(long = "list-plugins", action = ArgAction::SetTrue)]
357 pub list_plugins: bool,
358}
359
360impl Args {
361 pub fn test_default() -> Self {
363 Self {
364 paths: vec![],
365 help: None,
366 all: false,
367 almost_all: false,
368 long: false,
369 one_per_line: false,
370 columns: false,
371 commas: false,
372 human_readable: false,
373 si: false,
374 recursive: false,
375 reverse: false,
376 sort_time: false,
377 sort_size: false,
378 sort_extension: false,
379 sort_version: false,
380 sort_none: false,
381 sort: None,
382 time: None,
383 access_time: false,
384 change_time: false,
385 color: ColorArg::Auto,
386 json: false,
387 csv: false,
388 tsv: false,
389 tree: false,
390 gnu: false,
391 icons: IconsArg::Auto,
392 classify: false,
393 indicator_slash: false,
394 file_type: false,
395 indicator_style: None,
396 dirs_first: false,
397 directory: false,
398 ignore_backups: false,
399 ignore: vec![],
400 hide: vec![],
401 dereference: false,
402 dereference_command_line: false,
403 dereference_command_line_symlink_to_dir: false,
404 no_owner: false,
405 no_group_long: false,
406 no_group: false,
407 numeric_uid_gid: false,
408 inode: false,
409 size_blocks: false,
410 kibibytes: false,
411 block_size: None,
412 full_time: false,
413 time_style: None,
414 hide_control_chars: false,
415 show_control_chars: false,
416 escape: false,
417 quote_name: false,
418 literal: false,
419 quoting_style: None,
420 across: false,
421 unsorted_all: false,
422 format: None,
423 tabsize: None,
424 width: None,
425 context: false,
426 zero: false,
427 dired: false,
428 author: false,
429 hyperlink: None,
430 max_depth: None,
431 git: false,
432 config: None,
433 browse: false,
434 ignore_files: false,
435 no_ignore: false,
436 archive: true,
437 threads: 0,
438 profile: false,
439 io_uring: true,
440 generate_completions: None,
441 generate_man: false,
442 update: false,
443 check_update: false,
444 list_plugins: false,
445 }
446 }
447}
448
449#[derive(Debug, Clone, Copy, Default, ValueEnum)]
450pub enum ColorArg {
451 #[default]
452 Auto,
453 Always,
454 Never,
455}
456
457impl From<ColorArg> for f00_core::ColorWhen {
458 fn from(value: ColorArg) -> Self {
459 match value {
460 ColorArg::Auto => Self::Auto,
461 ColorArg::Always => Self::Always,
462 ColorArg::Never => Self::Never,
463 }
464 }
465}
466
467#[derive(Debug, Clone, Copy, Default, ValueEnum, PartialEq, Eq)]
469pub enum IconsArg {
470 #[default]
471 Auto,
472 Always,
473 Never,
474}
475
476impl From<IconsArg> for f00_core::IconsWhen {
477 fn from(value: IconsArg) -> Self {
478 match value {
479 IconsArg::Auto => Self::Auto,
480 IconsArg::Always => Self::Always,
481 IconsArg::Never => Self::Never,
482 }
483 }
484}
485
486impl From<f00_core::IconsWhen> for IconsArg {
487 fn from(value: f00_core::IconsWhen) -> Self {
488 match value {
489 f00_core::IconsWhen::Auto => Self::Auto,
490 f00_core::IconsWhen::Always => Self::Always,
491 f00_core::IconsWhen::Never => Self::Never,
492 }
493 }
494}