2020-04-03 21:24:11 +02:00
|
|
|
use std::{path::PathBuf, sync::Arc, time::Duration};
|
|
|
|
|
|
|
|
use lscolors::LsColors;
|
|
|
|
use regex::bytes::RegexSet;
|
|
|
|
|
2019-01-05 18:17:22 +01:00
|
|
|
use crate::exec::CommandTemplate;
|
2020-04-03 11:34:34 +02:00
|
|
|
use crate::filetypes::FileTypes;
|
2020-05-01 14:50:12 +02:00
|
|
|
#[cfg(unix)]
|
|
|
|
use crate::filter::OwnerFilter;
|
2020-04-03 11:36:54 +02:00
|
|
|
use crate::filter::{SizeFilter, TimeFilter};
|
2018-10-12 09:06:14 +02:00
|
|
|
|
|
|
|
/// Configuration options for *fd*.
|
2020-04-03 11:39:32 +02:00
|
|
|
pub struct Options {
|
2018-10-12 09:06:14 +02:00
|
|
|
/// Whether the search is case-sensitive or case-insensitive.
|
|
|
|
pub case_sensitive: bool,
|
|
|
|
|
|
|
|
/// Whether to search within the full file path or just the base name (filename or directory
|
|
|
|
/// name).
|
|
|
|
pub search_full_path: bool,
|
|
|
|
|
|
|
|
/// Whether to ignore hidden files and directories (or not).
|
|
|
|
pub ignore_hidden: bool,
|
|
|
|
|
|
|
|
/// Whether to respect `.fdignore` files or not.
|
|
|
|
pub read_fdignore: bool,
|
|
|
|
|
2021-08-08 23:38:24 +02:00
|
|
|
/// Whether to respect ignore files in parent directories or not.
|
|
|
|
pub read_parent_ignore: bool,
|
|
|
|
|
2018-10-12 09:06:14 +02:00
|
|
|
/// Whether to respect VCS ignore files (`.gitignore`, ..) or not.
|
|
|
|
pub read_vcsignore: bool,
|
|
|
|
|
2020-04-25 21:32:17 +02:00
|
|
|
/// Whether to respect the global ignore file or not.
|
|
|
|
pub read_global_ignore: bool,
|
|
|
|
|
2018-10-12 09:06:14 +02:00
|
|
|
/// Whether to follow symlinks or not.
|
|
|
|
pub follow_links: bool,
|
|
|
|
|
2019-11-14 21:55:40 +01:00
|
|
|
/// Whether to limit the search to starting file system or not.
|
2019-12-30 21:49:22 +01:00
|
|
|
pub one_file_system: bool,
|
2019-11-14 21:55:40 +01:00
|
|
|
|
2018-10-12 09:06:14 +02:00
|
|
|
/// Whether elements of output should be separated by a null character
|
|
|
|
pub null_separator: bool,
|
|
|
|
|
|
|
|
/// The maximum search depth, or `None` if no maximum search depth should be set.
|
|
|
|
///
|
|
|
|
/// A depth of `1` includes all files under the current directory, a depth of `2` also includes
|
|
|
|
/// all files under subdirectories of the current directory, etc.
|
|
|
|
pub max_depth: Option<usize>,
|
|
|
|
|
2020-04-15 16:17:01 +02:00
|
|
|
/// The minimum depth for reported entries, or `None`.
|
|
|
|
pub min_depth: Option<usize>,
|
|
|
|
|
2020-10-25 08:16:01 +01:00
|
|
|
/// Whether to stop traversing into matching directories.
|
|
|
|
pub prune: bool,
|
|
|
|
|
2018-10-12 09:06:14 +02:00
|
|
|
/// The number of threads to use.
|
|
|
|
pub threads: usize,
|
|
|
|
|
|
|
|
/// Time to buffer results internally before streaming to the console. This is useful to
|
|
|
|
/// provide a sorted output, in case the total execution time is shorter than
|
|
|
|
/// `max_buffer_time`.
|
|
|
|
pub max_buffer_time: Option<Duration>,
|
|
|
|
|
|
|
|
/// `None` if the output should not be colorized. Otherwise, a `LsColors` instance that defines
|
|
|
|
/// how to style different filetypes.
|
|
|
|
pub ls_colors: Option<LsColors>,
|
|
|
|
|
2020-04-04 12:51:15 +02:00
|
|
|
/// Whether or not we are writing to an interactive terminal
|
|
|
|
pub interactive_terminal: bool,
|
|
|
|
|
2018-10-12 09:06:14 +02:00
|
|
|
/// The type of file to search for. If set to `None`, all file types are displayed. If
|
|
|
|
/// set to `Some(..)`, only the types that are specified are shown.
|
|
|
|
pub file_types: Option<FileTypes>,
|
|
|
|
|
|
|
|
/// The extension to search for. Only entries matching the extension will be included.
|
|
|
|
///
|
|
|
|
/// The value (if present) will be a lowercase string without leading dots.
|
|
|
|
pub extensions: Option<RegexSet>,
|
|
|
|
|
|
|
|
/// If a value is supplied, each item found will be used to generate and execute commands.
|
2019-01-29 23:09:45 +01:00
|
|
|
pub command: Option<Arc<CommandTemplate>>,
|
2018-10-12 09:06:14 +02:00
|
|
|
|
|
|
|
/// A list of glob patterns that should be excluded from the search.
|
|
|
|
pub exclude_patterns: Vec<String>,
|
|
|
|
|
|
|
|
/// A list of custom ignore files.
|
|
|
|
pub ignore_files: Vec<PathBuf>,
|
|
|
|
|
|
|
|
/// The given constraints on the size of returned files
|
|
|
|
pub size_constraints: Vec<SizeFilter>,
|
|
|
|
|
|
|
|
/// Constraints on last modification time of files
|
|
|
|
pub time_constraints: Vec<TimeFilter>,
|
2018-10-22 14:20:08 +02:00
|
|
|
|
2020-05-01 14:50:12 +02:00
|
|
|
#[cfg(unix)]
|
|
|
|
/// User/group ownership constraint
|
|
|
|
pub owner_constraint: Option<OwnerFilter>,
|
|
|
|
|
2018-10-22 14:20:08 +02:00
|
|
|
/// Whether or not to display filesystem errors
|
|
|
|
pub show_filesystem_errors: bool,
|
2019-04-11 00:30:56 +02:00
|
|
|
|
|
|
|
/// The separator used to print file paths.
|
2019-04-12 01:33:51 +02:00
|
|
|
pub path_separator: Option<String>,
|
2020-04-02 17:52:44 +02:00
|
|
|
|
|
|
|
/// The maximum number of search results
|
|
|
|
pub max_results: Option<usize>,
|
2018-10-12 09:06:14 +02:00
|
|
|
}
|