Skip to content
Myr

config.rs

This file

Path

src/config.rs

132 lines · 4.4 KiB · Rust

Last changed by

Merge pull request #1216 from vegerot/pr1216David Peterbefore adoptionaf9daff

History of this file

Take it

1use std::{path::PathBuf, sync::Arc, time::Duration};23use lscolors::LsColors;4use regex::bytes::RegexSet;56use crate::exec::CommandSet;7use crate::filetypes::FileTypes;8#[cfg(unix)]9use crate::filter::OwnerFilter;10use crate::filter::{SizeFilter, TimeFilter};1112/// Configuration options for *fd*.13pub struct Config {14    /// Whether the search is case-sensitive or case-insensitive.15    pub case_sensitive: bool,1617    /// Whether to search within the full file path or just the base name (filename or directory18    /// name).19    pub search_full_path: bool,2021    /// Whether to ignore hidden files and directories (or not).22    pub ignore_hidden: bool,2324    /// Whether to respect `.fdignore` files or not.25    pub read_fdignore: bool,2627    /// Whether to respect ignore files in parent directories or not.28    pub read_parent_ignore: bool,2930    /// Whether to respect VCS ignore files (`.gitignore`, ..) or not.31    pub read_vcsignore: bool,3233    /// Whether to require a `.git` directory to respect gitignore files.34    pub require_git_to_read_vcsignore: bool,3536    /// Whether to respect the global ignore file or not.37    pub read_global_ignore: bool,3839    /// Whether to follow symlinks or not.40    pub follow_links: bool,4142    /// Whether to limit the search to starting file system or not.43    pub one_file_system: bool,4445    /// Whether elements of output should be separated by a null character46    pub null_separator: bool,4748    /// The maximum search depth, or `None` if no maximum search depth should be set.49    ///50    /// A depth of `1` includes all files under the current directory, a depth of `2` also includes51    /// all files under subdirectories of the current directory, etc.52    pub max_depth: Option<usize>,5354    /// The minimum depth for reported entries, or `None`.55    pub min_depth: Option<usize>,5657    /// Whether to stop traversing into matching directories.58    pub prune: bool,5960    /// The number of threads to use.61    pub threads: usize,6263    /// If true, the program doesn't print anything and will instead return an exit code of 064    /// if there's at least one match. Otherwise, the exit code will be 1.65    pub quiet: bool,6667    /// Time to buffer results internally before streaming to the console. This is useful to68    /// provide a sorted output, in case the total execution time is shorter than69    /// `max_buffer_time`.70    pub max_buffer_time: Option<Duration>,7172    /// `None` if the output should not be colorized. Otherwise, a `LsColors` instance that defines73    /// how to style different filetypes.74    pub ls_colors: Option<LsColors>,7576    /// Whether or not we are writing to an interactive terminal77    pub interactive_terminal: bool,7879    /// The type of file to search for. If set to `None`, all file types are displayed. If80    /// set to `Some(..)`, only the types that are specified are shown.81    pub file_types: Option<FileTypes>,8283    /// The extension to search for. Only entries matching the extension will be included.84    ///85    /// The value (if present) will be a lowercase string without leading dots.86    pub extensions: Option<RegexSet>,8788    /// If a value is supplied, each item found will be used to generate and execute commands.89    pub command: Option<Arc<CommandSet>>,9091    /// Maximum number of search results to pass to each `command`. If zero, the number is92    /// unlimited.93    pub batch_size: usize,9495    /// A list of glob patterns that should be excluded from the search.96    pub exclude_patterns: Vec<String>,9798    /// A list of custom ignore files.99    pub ignore_files: Vec<PathBuf>,100101    /// The given constraints on the size of returned files102    pub size_constraints: Vec<SizeFilter>,103104    /// Constraints on last modification time of files105    pub time_constraints: Vec<TimeFilter>,106107    #[cfg(unix)]108    /// User/group ownership constraint109    pub owner_constraint: Option<OwnerFilter>,110111    /// Whether or not to display filesystem errors112    pub show_filesystem_errors: bool,113114    /// The separator used to print file paths.115    pub path_separator: Option<String>,116117    /// The actual separator, either the system default separator or `path_separator`118    pub actual_path_separator: String,119120    /// The maximum number of search results121    pub max_results: Option<usize>,122123    /// Whether or not to strip the './' prefix for search results124    pub strip_cwd_prefix: bool,125}126127impl Config {128    /// Check whether results are being printed.129    pub fn is_printing(&self) -> bool {130        self.command.is_none()131    }132}