findit_cli/
cli_args.rs

1use std::path::PathBuf;
2
3use clap::Parser;
4
5/// Find files using powerful filtering expressions
6#[derive(Parser, Debug)]
7#[command(version, about, long_about = None )]
8pub struct CliArgs {
9    /// Root directory to search (default: current directory)
10    pub(crate) root: Option<PathBuf>,
11
12    /// Filter which files to display using an expression
13    ///
14    /// Examples:
15    ///   -w 'size > 1024'
16    ///   -w 'extension = "rs" AND NOT content.contains("test")'
17    #[arg(
18        short = 'w',
19        long = "where",
20        value_name = "FILTER",
21        visible_alias = "filter",
22        help_heading = "Filtering Options"
23    )]
24    pub(crate) filter: Vec<String>,
25
26    /// Sort results by an expression (add DESC for descending order)
27    ///
28    /// Examples:
29    ///   -o 'size DESC'
30    ///   -o 'modified, name'
31    #[arg(
32        short,
33        long,
34        value_name = "ORDER BY",
35        visible_alias = "sort",
36        visible_alias = "order",
37        visible_alias = "sort-by",
38        help_heading = "Output Ordering"
39    )]
40    pub(crate) order_by: Option<String>,
41
42    /// Maximum depth to recurse into directories
43    #[arg(short = 'x', long, help_heading = "Filtering Options")]
44    pub(crate) max_depth: Option<usize>,
45
46    /// Minimum depth to include files (0 = root level)
47    #[arg(short = 'n', long, help_heading = "Filtering Options")]
48    pub(crate) min_depth: Option<usize>,
49
50    /// Maximum number of results to display
51    #[arg(short, long, help_heading = "Filtering Options")]
52    pub(crate) limit: Option<usize>,
53
54    /// Custom output format using expressions in backticks (or `--interpolation-start` and `--interpolation-end`)
55    ///
56    /// Example:
57    ///   -d 'File: `name`, Size: `size` bytes'
58    #[arg(
59        short,
60        long,
61        visible_alias = "show",
62        visible_alias = "print",
63        value_name = "DISPLAY",
64        help_heading = "Output Formatting"
65    )]
66    pub(crate) display: Option<String>,
67
68    /// Start marker for expressions in display format
69    #[arg(
70        long,
71        default_value = "`",
72        visible_alias = "expr-start",
73        help_heading = "Output Formatting"
74    )]
75    pub(crate) interpolation_start: String,
76
77    /// End marker for expressions in display format
78    #[arg(
79        long,
80        default_value = "`",
81        visible_alias = "expr-end",
82        help_heading = "Output Formatting"
83    )]
84    pub(crate) interpolation_end: String,
85
86    /// Process files before their parent directories
87    #[arg(
88        long,
89        default_value_t = false,
90        visible_alias = "files-first",
91        visible_alias = "depth-first",
92        help_heading = "Output Ordering"
93    )]
94    pub(crate) node_first: bool,
95
96    /// Write debug information to a file
97    #[arg(
98        long,
99        value_name = "DEBUG_FILE",
100        visible_alias = "debug-log",
101        help_heading = "Developer Options"
102    )]
103    pub(crate) debug_output_file: Option<PathBuf>,
104
105    /// Show syntax help and examples
106    #[arg(long, help_heading = "Developer Options")]
107    pub(crate) help_syntax: bool,
108}