agcodex_file_search/
cli.rs

1use std::num::NonZero;
2use std::path::PathBuf;
3
4use clap::ArgAction;
5use clap::Parser;
6
7/// Fuzzy matches filenames under a directory.
8#[derive(Parser)]
9#[command(version)]
10pub struct Cli {
11    /// Whether to output results in JSON format.
12    #[clap(long, default_value = "false")]
13    pub json: bool,
14
15    /// Maximum number of results to return.
16    #[clap(long, short = 'l', default_value = "64")]
17    pub limit: NonZero<usize>,
18
19    /// Directory to search.
20    #[clap(long, short = 'C')]
21    pub cwd: Option<PathBuf>,
22
23    /// Include matching file indices in the output.
24    #[arg(long, default_value = "false")]
25    pub compute_indices: bool,
26
27    // While it is common to default to the number of logical CPUs when creating
28    // a thread pool, empirically, the I/O of the filetree traversal offers
29    // limited parallelism and is the bottleneck, so using a smaller number of
30    // threads is more efficient. (Empirically, using more than 2 threads doesn't seem to provide much benefit.)
31    //
32    /// Number of worker threads to use.
33    #[clap(long, default_value = "2")]
34    pub threads: NonZero<usize>,
35
36    /// Exclude patterns
37    #[arg(short, long, action = ArgAction::Append)]
38    pub exclude: Vec<String>,
39
40    /// Search pattern.
41    pub pattern: Option<String>,
42}