mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-19 02:10:34 +01:00
Move FdOptions to Options
This commit is contained in:
parent
9f738ad995
commit
65096a653e
5 changed files with 15 additions and 14 deletions
|
@ -4,8 +4,6 @@ use std::ffi::{OsStr, OsString};
|
|||
use regex_syntax::hir::Hir;
|
||||
use regex_syntax::ParserBuilder;
|
||||
|
||||
pub mod opts;
|
||||
|
||||
macro_rules! print_error {
|
||||
($($arg:tt)*) => (eprintln!("[fd error]: {}", format!($($arg)*)))
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ mod exit_codes;
|
|||
mod filetypes;
|
||||
mod filter;
|
||||
mod fshelper;
|
||||
mod options;
|
||||
mod output;
|
||||
mod walk;
|
||||
|
||||
|
@ -24,7 +25,8 @@ use regex::bytes::{RegexBuilder, RegexSetBuilder};
|
|||
use crate::exec::CommandTemplate;
|
||||
use crate::filetypes::FileTypes;
|
||||
use crate::filter::{SizeFilter, TimeFilter};
|
||||
use crate::internal::{opts::FdOptions, pattern_has_uppercase_char, transform_args_with_exec};
|
||||
use crate::internal::{pattern_has_uppercase_char, transform_args_with_exec};
|
||||
use crate::options::Options;
|
||||
|
||||
// We use jemalloc for performance reasons, see https://github.com/sharkdp/fd/pull/481
|
||||
#[cfg(all(not(windows), not(target_env = "musl")))]
|
||||
|
@ -208,7 +210,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
let config = FdOptions {
|
||||
let config = Options {
|
||||
case_sensitive,
|
||||
search_full_path: matches.is_present("full-path"),
|
||||
ignore_hidden: !(matches.is_present("hidden")
|
||||
|
|
|
@ -6,7 +6,7 @@ use regex::bytes::RegexSet;
|
|||
use std::{path::PathBuf, sync::Arc, time::Duration};
|
||||
|
||||
/// Configuration options for *fd*.
|
||||
pub struct FdOptions {
|
||||
pub struct Options {
|
||||
/// Whether the search is case-sensitive or case-insensitive.
|
||||
pub case_sensitive: bool,
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::exit_codes::ExitCode;
|
||||
use crate::internal::opts::FdOptions;
|
||||
use crate::options::Options;
|
||||
use lscolors::{LsColors, Style};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
@ -24,7 +24,7 @@ fn strip_current_dir(pathbuf: &PathBuf) -> &Path {
|
|||
pub fn print_entry(
|
||||
stdout: &mut StdoutLock,
|
||||
entry: &PathBuf,
|
||||
config: &FdOptions,
|
||||
config: &Options,
|
||||
wants_to_quit: &Arc<AtomicBool>,
|
||||
) {
|
||||
let path = if entry.is_absolute() {
|
||||
|
@ -45,7 +45,7 @@ pub fn print_entry(
|
|||
}
|
||||
}
|
||||
|
||||
fn replace_path_separator<'a>(config: &FdOptions, path: &mut Cow<'a, str>) {
|
||||
fn replace_path_separator<'a>(config: &Options, path: &mut Cow<'a, str>) {
|
||||
match &config.path_separator {
|
||||
None => {}
|
||||
Some(sep) => {
|
||||
|
@ -57,7 +57,7 @@ fn replace_path_separator<'a>(config: &FdOptions, path: &mut Cow<'a, str>) {
|
|||
fn print_entry_colorized(
|
||||
stdout: &mut StdoutLock,
|
||||
path: &Path,
|
||||
config: &FdOptions,
|
||||
config: &Options,
|
||||
ls_colors: &LsColors,
|
||||
wants_to_quit: &Arc<AtomicBool>,
|
||||
) -> io::Result<()> {
|
||||
|
@ -89,7 +89,7 @@ fn print_entry_colorized(
|
|||
fn print_entry_uncolorized(
|
||||
stdout: &mut StdoutLock,
|
||||
path: &Path,
|
||||
config: &FdOptions,
|
||||
config: &Options,
|
||||
) -> io::Result<()> {
|
||||
let separator = if config.null_separator { "\0" } else { "\n" };
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::exec;
|
||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||
use crate::fshelper;
|
||||
use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};
|
||||
use crate::internal::{osstr_to_bytes, MAX_BUFFER_LENGTH};
|
||||
use crate::options::Options;
|
||||
use crate::output;
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
@ -41,7 +42,7 @@ pub enum WorkerResult {
|
|||
/// If the `--exec` argument was supplied, this will create a thread pool for executing
|
||||
/// jobs in parallel from a given command line and the discovered paths. Otherwise, each
|
||||
/// path will simply be written to standard output.
|
||||
pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) -> ExitCode {
|
||||
pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Options>) -> ExitCode {
|
||||
let mut path_iter = path_vec.iter();
|
||||
let first_path_buf = path_iter
|
||||
.next()
|
||||
|
@ -132,7 +133,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) -
|
|||
}
|
||||
|
||||
fn spawn_receiver(
|
||||
config: &Arc<FdOptions>,
|
||||
config: &Arc<Options>,
|
||||
wants_to_quit: &Arc<AtomicBool>,
|
||||
rx: Receiver<WorkerResult>,
|
||||
) -> thread::JoinHandle<ExitCode> {
|
||||
|
@ -285,7 +286,7 @@ impl DirEntry {
|
|||
}
|
||||
|
||||
fn spawn_senders(
|
||||
config: &Arc<FdOptions>,
|
||||
config: &Arc<Options>,
|
||||
wants_to_quit: &Arc<AtomicBool>,
|
||||
pattern: Arc<Regex>,
|
||||
parallel_walker: ignore::WalkParallel,
|
||||
|
|
Loading…
Reference in a new issue