feat: standalone file search CLI (#1386)
Standalone fuzzy filename search library that should be helpful in addressing https://github.com/openai/codex/issues/1261.
This commit is contained in:
38
codex-rs/file-search/src/cli.rs
Normal file
38
codex-rs/file-search/src/cli.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use std::num::NonZero;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::ArgAction;
|
||||
use clap::Parser;
|
||||
|
||||
/// Fuzzy matches filenames under a directory.
|
||||
#[derive(Parser)]
|
||||
#[command(version)]
|
||||
pub struct Cli {
|
||||
/// Whether to output results in JSON format.
|
||||
#[clap(long, default_value = "false")]
|
||||
pub json: bool,
|
||||
|
||||
/// Maximum number of results to return.
|
||||
#[clap(long, short = 'l', default_value = "64")]
|
||||
pub limit: NonZero<usize>,
|
||||
|
||||
/// Directory to search.
|
||||
#[clap(long, short = 'C')]
|
||||
pub cwd: Option<PathBuf>,
|
||||
|
||||
// While it is common to default to the number of logical CPUs when creating
|
||||
// a thread pool, empirically, the I/O of the filetree traversal offers
|
||||
// limited parallelism and is the bottleneck, so using a smaller number of
|
||||
// threads is more efficient. (Empirically, using more than 2 threads doesn't seem to provide much benefit.)
|
||||
//
|
||||
/// Number of worker threads to use.
|
||||
#[clap(long, default_value = "2")]
|
||||
pub threads: NonZero<usize>,
|
||||
|
||||
/// Exclude patterns
|
||||
#[arg(short, long, action = ArgAction::Append)]
|
||||
pub exclude: Vec<String>,
|
||||
|
||||
/// Search pattern.
|
||||
pub pattern: Option<String>,
|
||||
}
|
||||
Reference in New Issue
Block a user