mirror of
https://github.com/sharkdp/fd
synced 2024-10-04 14:59:15 +00:00
[ownership] add --owner arg parsing and storage
This commit is contained in:
parent
30cb4adc61
commit
4f9a02400a
|
@ -524,6 +524,15 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
),
|
||||
);
|
||||
|
||||
if cfg!(unix) {
|
||||
app = app.arg(
|
||||
Arg::with_name("owner")
|
||||
.long("owner")
|
||||
.short("o")
|
||||
.takes_value(true),
|
||||
);
|
||||
}
|
||||
|
||||
// Make `--one-file-system` available only on Unix and Windows platforms, as per the
|
||||
// restrictions on the corresponding option in the `ignore` crate.
|
||||
// Provide aliases `mount` and `xdev` for people coming from `find`.
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -25,6 +25,8 @@ use regex::bytes::{RegexBuilder, RegexSetBuilder};
|
|||
use crate::exec::CommandTemplate;
|
||||
use crate::exit_codes::ExitCode;
|
||||
use crate::filetypes::FileTypes;
|
||||
#[cfg(unix)]
|
||||
use crate::filter::OwnerFilter;
|
||||
use crate::filter::{SizeFilter, TimeFilter};
|
||||
use crate::options::Options;
|
||||
use crate::regex_helper::pattern_has_uppercase_char;
|
||||
|
@ -275,6 +277,13 @@ fn run() -> Result<ExitCode> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
let owner_constraint = if let Some(s) = matches.value_of("owner") {
|
||||
Some(OwnerFilter::from_string(s)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let config = Options {
|
||||
case_sensitive,
|
||||
search_full_path: matches.is_present("full-path"),
|
||||
|
@ -358,6 +367,8 @@ fn run() -> Result<ExitCode> {
|
|||
.unwrap_or_else(|| vec![]),
|
||||
size_constraints: size_limits,
|
||||
time_constraints,
|
||||
#[cfg(unix)]
|
||||
owner_constraint,
|
||||
show_filesystem_errors: matches.is_present("show-errors"),
|
||||
path_separator,
|
||||
max_results: matches
|
||||
|
|
|
@ -5,6 +5,8 @@ use regex::bytes::RegexSet;
|
|||
|
||||
use crate::exec::CommandTemplate;
|
||||
use crate::filetypes::FileTypes;
|
||||
#[cfg(unix)]
|
||||
use crate::filter::OwnerFilter;
|
||||
use crate::filter::{SizeFilter, TimeFilter};
|
||||
|
||||
/// Configuration options for *fd*.
|
||||
|
@ -82,6 +84,10 @@ pub struct Options {
|
|||
/// Constraints on last modification time of files
|
||||
pub time_constraints: Vec<TimeFilter>,
|
||||
|
||||
#[cfg(unix)]
|
||||
/// User/group ownership constraint
|
||||
pub owner_constraint: Option<OwnerFilter>,
|
||||
|
||||
/// Whether or not to display filesystem errors
|
||||
pub show_filesystem_errors: bool,
|
||||
|
||||
|
|
Loading…
Reference in a new issue