[ownership] add --owner arg parsing and storage
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Alexandru Macovei · committed by David Peter · parent 30cb4ad · Browse files · 3 files·+26 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+26 added−0 removed
- other:+26 added−0 removed
Provenance
- Commit
4f9a024- Tree
0278ba4- Author
Alexandru Macovei <alexnmaco@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
30cb4ad
3 files changed+26 added−0 removed
modified:src/app.rs+9 added
522 unmodified lines523 --search-path <path2> [<pattern>]`",524 ),525 );526 527+ if cfg!(unix) {528+ app = app.arg(529+ Arg::with_name("owner")530+ .long("owner")531+ .short("o")532+ .takes_value(true),533+ );534+ }535+536 // Make `--one-file-system` available only on Unix and Windows platforms, as per the537 // restrictions on the corresponding option in the `ignore` crate.538 // Provide aliases `mount` and `xdev` for people coming from `find`.539 if cfg!(any(unix, windows)) {16 unmodified linesmodified:src/main.rs+11 added
23 unmodified lines24 25 use crate::exec::CommandTemplate;26 use crate::exit_codes::ExitCode;27 use crate::filetypes::FileTypes;28+#[cfg(unix)]29+use crate::filter::OwnerFilter;30 use crate::filter::{SizeFilter, TimeFilter};31 use crate::options::Options;32 use crate::regex_helper::pattern_has_uppercase_char;33 242 unmodified lines276 ));277 }278 }279 280+ #[cfg(unix)]281+ let owner_constraint = if let Some(s) = matches.value_of("owner") {282+ Some(OwnerFilter::from_string(s)?)283+ } else {284+ None285+ };286+287 let config = Options {288 case_sensitive,289 search_full_path: matches.is_present("full-path"),290 ignore_hidden: !(matches.is_present("hidden")75 unmodified lines366 .map(|vs| vs.map(PathBuf::from).collect())367 .unwrap_or_else(|| vec![]),368 size_constraints: size_limits,369 time_constraints,370+ #[cfg(unix)]371+ owner_constraint,372 show_filesystem_errors: matches.is_present("show-errors"),373 path_separator,374 max_results: matches375 .value_of("max-results")39 unmodified linesmodified:src/options.rs+6 added
3 unmodified lines4 use regex::bytes::RegexSet;5 6 use crate::exec::CommandTemplate;7 use crate::filetypes::FileTypes;8+#[cfg(unix)]9+use crate::filter::OwnerFilter;10 use crate::filter::{SizeFilter, TimeFilter};11 12 /// Configuration options for *fd*.13 pub struct Options {69 unmodified lines83 84 /// Constraints on last modification time of files85 pub time_constraints: Vec<TimeFilter>,86 87+ #[cfg(unix)]88+ /// User/group ownership constraint89+ pub owner_constraint: Option<OwnerFilter>,90+91 /// Whether or not to display filesystem errors92 pub show_filesystem_errors: bool,93 94 /// The separator used to print file paths.5 unmodified lines