Make help output more like what it was before use clap_derive

In particular, we specifically use `long_help` instead of doc comments
because using  doc comments will always trim the "." off the end of the
first paragraph, and will include the short help as the first paragraph
of the full help.
This commit is contained in:
Thayne McCombs 2022-11-01 02:30:22 -06:00
parent 8500c3193d
commit 36ee44a3f6
1 changed files with 317 additions and 236 deletions

View File

@ -84,8 +84,6 @@ impl clap::Args for Negations {
#[derive(Parser)] #[derive(Parser)]
#[command( #[command(
version, version,
after_help = "Note: `fd -h` prints a short and concise overview while `fd --help` gives all \
details.",
after_long_help = "Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues", after_long_help = "Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues",
args_override_self = true, args_override_self = true,
group(ArgGroup::new("execs").args(&["exec", "exec_batch", "list_details"]).conflicts_with_all(&[ group(ArgGroup::new("execs").args(&["exec", "exec_batch", "list_details"]).conflicts_with_all(&[
@ -93,208 +91,269 @@ impl clap::Args for Negations {
)] )]
pub struct Opts { pub struct Opts {
/// Search hidden files and directories /// Search hidden files and directories
/// #[arg(
/// Include hidden directories and files in the search results (default: long,
/// hidden files and directories are skipped). Files and directories are considered short = 'H',
/// to be hidden if their name starts with a `.` sign (dot). long_help = "Include hidden directories and files in the search results (default: \
/// The flag can be overridden with --no-hidden. hidden files and directories are skipped). Files and directories are \
#[arg(long, short = 'H')] considered to be hidden if their name starts with a `.` sign (dot). \
The flag can be overridden with --no-hidden."
)]
pub hidden: bool, pub hidden: bool,
/// Do not respect .(git|fd)ignore files /// Do not respect .(git|fd)ignore files
/// #[arg(
/// Show search results from files and directories that would otherwise be long,
/// ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file. short = 'I',
/// The flag can be overridden with --ignore. long_help = "Show search results from files and directories that would otherwise be \
#[arg(long, short = 'I')] ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file. \
The flag can be overridden with --ignore."
)]
pub no_ignore: bool, pub no_ignore: bool,
/// Do not respect .gitignore files /// Do not respect .gitignore files
/// #[arg(
///Show search results from files and directories that would otherwise be long,
///ignored by '.gitignore' files. The flag can be overridden with --ignore-vcs. hide_short_help = true,
#[arg(long, hide_short_help = true)] long_help = "Show search results from files and directories that would otherwise be \
ignored by '.gitignore' files. The flag can be overridden with --ignore-vcs."
)]
pub no_ignore_vcs: bool, pub no_ignore_vcs: bool,
/// Do not respect .(git|fd)ignore files in parent directories /// Do not respect .(git|fd)ignore files in parent directories
/// #[arg(
/// Show search results from files and directories that would otherwise be long,
/// ignored by '.gitignore', '.ignore', or '.fdignore' files in parent directories. hide_short_help = true,
#[arg(long, hide_short_help = true)] long_help = "Show search results from files and directories that would otherwise be \
ignored by '.gitignore', '.ignore', or '.fdignore' files in parent directories."
)]
pub no_ignore_parent: bool, pub no_ignore_parent: bool,
/// Do not respect the global ignore file /// Do not respect the global ignore file
#[arg(long, hide = true)] #[arg(long, hide = true)]
pub no_global_ignore_file: bool, pub no_global_ignore_file: bool,
///Perform an unrestricted search, including ignored and hidden files. This is /// Unrestricted search, alias for '--no-ignore --hidden'
///an alias for '--no-ignore --hidden'. #[arg(long = "unrestricted", short = 'u', overrides_with_all(&["ignore", "no_hidden"]), action(ArgAction::Count), hide_short_help = true,
#[arg(long = "unrestricted", short = 'u', overrides_with_all(&["ignore", "no_hidden"]), action(ArgAction::Count), hide_short_help = true)] long_help = "Perform an unrestricted search, including ignored and hidden files. This is \
an alias for '--no-ignore --hidden'."
)]
rg_alias_hidden_ignore: u8, rg_alias_hidden_ignore: u8,
/// Case-sensitive search (default: smart case) /// Case-sensitive search (default: smart case)
/// #[arg(
///Perform a case-sensitive search. By default, fd uses case-insensitive long,
///searches, unless the pattern contains an uppercase character (smart case). short = 's',
#[arg(long, short = 's', overrides_with("ignore_case"))] overrides_with("ignore_case"),
long_help = "Perform a case-sensitive search. By default, fd uses case-insensitive \
searches, unless the pattern contains an uppercase character (smart \
case)."
)]
pub case_sensitive: bool, pub case_sensitive: bool,
/// Case-insensitive search (default: smart case) /// Case-insensitive search (default: smart case)
/// #[arg(
/// Perform a case-insensitive search. By default, fd uses case-insensitive searches, unless long,
/// the pattern contains an uppercase character (smart case). short = 'i',
#[arg(long, short = 'i', overrides_with("case_sensitive"))] overrides_with("case_sensitive"),
long_help = "Perform a case-insensitive search. By default, fd uses case-insensitive \
searches, unless the pattern contains an uppercase character (smart \
case)."
)]
pub ignore_case: bool, pub ignore_case: bool,
/// Glob-based search (default: regular expression) /// Glob-based search (default: regular expression)
/// #[arg(
/// Perform a glob-based search instead of a regular expression search. long,
#[arg(long, short = 'g', conflicts_with("fixed_strings"))] short = 'g',
conflicts_with("fixed_strings"),
long_help = "Perform a glob-based search instead of a regular expression search."
)]
pub glob: bool, pub glob: bool,
/// Perform a regular-expression based search (default). This can be used to override --glob. /// Regular-expression based search (default)
#[arg(long, overrides_with("glob"), hide_short_help = true)] #[arg(
long,
overrides_with("glob"),
hide_short_help = true,
long_help = "Perform a regular-expression based search (default). This can be used to \
override --glob."
)]
pub regex: bool, pub regex: bool,
/// Treat the pattern as a literal string instead of a regular expression. Note /// Treat pattern as literal string stead of regex
/// that this also performs substring comparison. If you want to match on an #[arg(
/// exact filename, consider using '--glob'. long,
#[arg(long, short = 'F', alias = "literal", hide_short_help = true)] short = 'F',
alias = "literal",
hide_short_help = true,
long_help = "Treat the pattern as a literal string instead of a regular expression. Note \
that this also performs substring comparison. If you want to match on an \
exact filename, consider using '--glob'."
)]
pub fixed_strings: bool, pub fixed_strings: bool,
/// Show absolute instead of relative paths /// Show absolute instead of relative paths
/// #[arg(
/// Shows the full path starting with the root as opposed to relative paths. long,
/// The flag can be overridden with --relative-path. short = 'a',
#[arg(long, short = 'a')] long_help = "Shows the full path starting from the root as opposed to relative paths. \
The flag can be overridden with --relative-path."
)]
pub absolute_path: bool, pub absolute_path: bool,
/// Use a long listing format with file metadata /// Use a long listing format with file metadata
/// #[arg(
/// Use a detailed listing format like 'ls -l'. This is basically an alias long,
/// for '--exec-batch ls -l' with some additional 'ls' options. This can be short = 'l',
/// used to see more metadata, to show symlink targets and to achieve a conflicts_with("absolute_path"),
/// deterministic sort order. long_help = "Use a detailed listing format like 'ls -l'. This is basically an alias \
#[arg(long, short = 'l', conflicts_with("absolute_path"))] for '--exec-batch ls -l' with some additional 'ls' options. This can be \
used to see more metadata, to show symlink targets and to achieve a \
deterministic sort order."
)]
pub list_details: bool, pub list_details: bool,
/// Follow symbolic links /// Follow symbolic links
/// #[arg(
/// By default, fd does not descend into symlinked directories. Using this long,
/// flag, symbolic links are also traversed. short = 'L',
/// Flag can be overridden with --no-follow. alias = "dereference",
#[arg(long, short = 'L', alias = "dereference")] long_help = "By default, fd does not descend into symlinked directories. Using this \
flag, symbolic links are also traversed. \
Flag can be overriden with --no-follow."
)]
pub follow: bool, pub follow: bool,
/// Search full abs. path (default: filename only) /// Search full abs. path (default: filename only)
/// #[arg(
/// By default, the search pattern is only matched against the filename (or long,
/// directory name). Using this flag, the pattern is matched against the full short = 'p',
/// (absolute) path. long_help = "By default, the search pattern is only matched against the filename (or \
/// Example: directory name). Using this flag, the pattern is matched against the full \
/// fd --glob -p '**/.git/config' (absolute) path. Example:\n \
#[arg(long, short = 'p', verbatim_doc_comment)] fd --glob -p '**/.git/config'"
)]
pub full_path: bool, pub full_path: bool,
/// Separate search results by the null character (instead of newlines). /// Separate search results by the null character
/// Useful for piping results to 'xargs'.
#[arg( #[arg(
long = "print0", long = "print0",
short = '0', short = '0',
conflicts_with("list_details"), conflicts_with("list_details"),
hide_short_help = true hide_short_help = true,
long_help = "Separate search results by the null character (instead of newlines). \
Useful for piping results to 'xargs'."
)] )]
pub null_separator: bool, pub null_separator: bool,
/// Set maximum search depth (default: none) /// Set maximum search depth (default: none)
/// #[arg(
/// Limit the directory traversal to a given depth. By default, there is no long,
/// limit on the search depth. short = 'd',
#[arg(long, short = 'd', value_name = "depth", alias("maxdepth"))] value_name = "depth",
alias("maxdepth"),
long_help = "Limit the directory traversal to a given depth. By default, there is no \
limit on the search depth."
)]
max_depth: Option<usize>, max_depth: Option<usize>,
/// Only show search results starting at the given depth. /// Only show search results starting at the given depth.
/// See also: '--max-depth' and '--exact-depth' #[arg(
#[arg(long, value_name = "depth", hide_short_help = true)] long,
value_name = "depth",
hide_short_help = true,
long_help = "Only show search results starting at the given depth. \
See also: '--max-depth' and '--exact-depth'"
)]
min_depth: Option<usize>, min_depth: Option<usize>,
/// Only show search results at the exact given depth. This is an alias for /// Only show search results at the exact given depth
/// '--min-depth <depth> --max-depth <depth>'. #[arg(long, value_name = "depth", hide_short_help = true, conflicts_with_all(&["max_depth", "min_depth"]),
#[arg(long, value_name = "depth", hide_short_help = true, conflicts_with_all(&["max_depth", "min_depth"]))] long_help = "Only show search results at the exact given depth. This is an alias for \
'--min-depth <depth> --max-depth <depth>'.",
)]
exact_depth: Option<usize>, exact_depth: Option<usize>,
/// Do not traverse into directories that match the search criteria. If /// Do not traverse into directories that match the search criteria. If
/// you want to exclude specific directories, use the '--exclude=…' option. /// you want to exclude specific directories, use the '--exclude=…' option.
#[arg(long, hide_short_help = true, conflicts_with_all(&["size", "exact_depth"]))] #[arg(long, hide_short_help = true, conflicts_with_all(&["size", "exact_depth"]),
long_help = "Do not traverse into directories that match the search criteria. If \
you want to exclude specific directories, use the '--exclude=' option.",
)]
pub prune: bool, pub prune: bool,
/// Filter by type: file (f), directory (d), symlink (l), /// Filter by type: file (f), directory (d), symlink (l),
/// executable (x), empty (e), socket (s), pipe (p) /// executable (x), empty (e), socket (s), pipe (p)
///
/// Filter the search by type:
///
/// 'f' or 'file': regular files
/// 'd' or 'directory': directories
/// 'l' or 'symlink': symbolic links
/// 's' or 'socket': socket
/// 'p' or 'pipe': named pipe (FIFO)
///
/// 'x' or 'executable': executables
/// 'e' or 'empty': empty files or directories
///
/// This option can be specified more than once to include multiple file types.
/// Searching for '--type file --type symlink' will show both regular files as
/// well as symlinks. Note that the 'executable' and 'empty' filters work differently:
/// '--type executable' implies '--type file' by default. And '--type empty' searches
/// for empty files and directories, unless either '--type file' or '--type directory'
/// is specified in addition.
///
/// Examples:
///
/// - Only search for files:
/// fd --type file …
/// fd -tf …
/// - Find both files and symlinks
/// fd --type file --type symlink …
/// fd -tf -tl …
/// - Find executable files:
/// fd --type executable
/// fd -tx
/// - Find empty files:
/// fd --type empty --type file
/// fd -te -tf
/// - Find empty directories:
/// fd --type empty --type directory
/// fd -te -td"
#[arg( #[arg(
long = "type", long = "type",
short = 't', short = 't',
value_name = "filetype", value_name = "filetype",
hide_possible_values = true, hide_possible_values = true,
value_enum, value_enum,
verbatim_doc_comment long_help = "Filter the search by type:\n \
'f' or 'file': regular files\n \
'd' or 'directory': directories\n \
'l' or 'symlink': symbolic links\n \
's' or 'socket': socket\n \
'p' or 'pipe': named pipe (FIFO)\n\n \
'x' or 'executable': executables\n \
'e' or 'empty': empty files or directories\n\n\
This option can be specified more than once to include multiple file types. \
Searching for '--type file --type symlink' will show both regular files as \
well as symlinks. Note that the 'executable' and 'empty' filters work differently: \
'--type executable' implies '--type file' by default. And '--type empty' searches \
for empty files and directories, unless either '--type file' or '--type directory' \
is specified in addition.\n\n\
Examples:\n \
- Only search for files:\n \
fd --type file \n \
fd -tf \n \
- Find both files and symlinks\n \
fd --type file --type symlink \n \
fd -tf -tl \n \
- Find executable files:\n \
fd --type executable\n \
fd -tx\n \
- Find empty files:\n \
fd --type empty --type file\n \
fd -te -tf\n \
- Find empty directories:\n \
fd --type empty --type directory\n \
fd -te -td"
)] )]
pub filetype: Option<Vec<FileType>>, pub filetype: Option<Vec<FileType>>,
/// Filter by file extension /// Filter by file extension
/// #[arg(
/// (Additionally) filter search results by their file extension. Multiple long = "extension",
/// allowable file extensions can be specified. short = 'e',
/// If you want to search for files without extension, value_name = "ext",
/// you can use the regex '^[^.]+$' as a normal search pattern. long_help = "(Additionally) filter search results by their file extension. Multiple \
#[arg(long = "extension", short = 'e', value_name = "ext")] allowable file extensions can be specified.\n\
If you want to search for files without extension, \
you can use the regex '^[^.]+$' as a normal search pattern."
)]
pub extensions: Option<Vec<String>>, pub extensions: Option<Vec<String>>,
#[command(flatten)] #[command(flatten)]
pub exec: Exec, pub exec: Exec,
/// Maximum number of arguments to pass to the command given with -X. /// Max number of arguments to run as a batch size with -X
/// If the number of results is greater than the given size,
/// the command given with -X is run again with remaining arguments.
/// A batch size of zero means there is no limit (default), but note
/// that batching might still happen due to OS restrictions on the
/// maximum length of command lines.
#[arg( #[arg(
long, long,
value_name = "size", value_name = "size",
hide_short_help = true, hide_short_help = true,
requires("exec_batch"), requires("exec_batch"),
value_parser = value_parser!(usize), value_parser = value_parser!(usize),
default_value_t default_value_t,
long_help = "Maximum number of arguments to pass to the command given with -X. \
If the number of results is greater than the given size, \
the command given with -X is run again with remaining arguments. \
A batch size of zero means there is no limit (default), but note \
that batching might still happen due to OS restrictions on the \
maximum length of command lines.",
)] )]
pub batch_size: usize, pub batch_size: usize,
/// Exclude entries that match the given glob pattern /// Exclude entries that match the given glob pattern
/// #[arg(
/// Exclude files/directories that match the given glob pattern. This overrides any other long,
/// ignore logic. Multiple exclude patterns can be specified. short = 'E',
/// value_name = "pattern",
/// Examples: long_help = "Exclude files/directories that match the given glob pattern. This \
/// --exclude '*.pyc' overrides any other ignore logic. Multiple exclude patterns can be \
/// --exclude node_modules specified.\n\n\
#[arg(long, short = 'E', value_name = "pattern", verbatim_doc_comment)] Examples:\n \
--exclude '*.pyc'\n \
--exclude node_modules"
)]
pub exclude: Vec<String>, pub exclude: Vec<String>,
/// Add a custom ignore-file in '.gitignore' format. These files have a low /// Add a custom ignore-file in '.gitignore' format
/// precedence. #[arg(
#[arg(long, value_name = "path", hide_short_help = true)] long,
value_name = "path",
hide_short_help = true,
long_help = "Add a custom ignore-file in '.gitignore' format. These files have a low precedence"
)]
pub ignore_file: Vec<PathBuf>, pub ignore_file: Vec<PathBuf>,
/// When to use colors /// When to use colors
#[arg( #[arg(
@ -303,7 +362,7 @@ pub struct Opts {
value_enum, value_enum,
default_value_t = ColorWhen::Auto, default_value_t = ColorWhen::Auto,
value_name = "when", value_name = "when",
verbatim_doc_comment long_help = "Declare when to use color for the pattern match output",
)] )]
pub color: ColorWhen, pub color: ColorWhen,
/// Set number of threads to use for searching & executing (default: number /// Set number of threads to use for searching & executing (default: number
@ -311,24 +370,24 @@ pub struct Opts {
#[arg(long, short = 'j', value_name = "num", hide_short_help = true, value_parser = 1..)] #[arg(long, short = 'j', value_name = "num", hide_short_help = true, value_parser = 1..)]
pub threads: Option<u32>, pub threads: Option<u32>,
/// Limit results based on the size of files /// Limit results based on the size of files
/// #[arg(long, short = 'S', value_parser = SizeFilter::from_string, allow_hyphen_values = true, verbatim_doc_comment, value_name = "size",
/// Limit results based on the size of files using the format <+-><NUM><UNIT>. long_help = "Limit results based on the size of files using the format <+-><NUM><UNIT>.\n \
/// '+': file size must be greater than or equal to this '+': file size must be greater than or equal to this\n \
/// '-': file size must be less than or equal to this '-': file size must be less than or equal to this\n\
/// If neither '+' nor '-' is specified, file size must be exactly equal to this. If neither '+' nor '-' is specified, file size must be exactly equal to this.\n \
/// 'NUM': The numeric size (e.g. 500) 'NUM': The numeric size (e.g. 500)\n \
/// 'UNIT': The units for NUM. They are not case-sensitive. 'UNIT': The units for NUM. They are not case-sensitive.\n\
/// Allowed unit values: Allowed unit values:\n \
/// 'b': bytes 'b': bytes\n \
/// 'k': kilobytes (base ten, 10^3 = 1000 bytes) 'k': kilobytes (base ten, 10^3 = 1000 bytes)\n \
/// 'm': megabytes 'm': megabytes\n \
/// 'g': gigabytes 'g': gigabytes\n \
/// 't': terabytes 't': terabytes\n \
/// 'ki': kibibytes (base two, 2^10 = 1024 bytes) 'ki': kibibytes (base two, 2^10 = 1024 bytes)\n \
/// 'mi': mebibytes 'mi': mebibytes\n \
/// 'gi': gibibytes 'gi': gibibytes\n \
/// 'ti': tebibytes 'ti': tebibytes",
#[arg(long, short = 'S', value_parser = SizeFilter::from_string, allow_hyphen_values = true, verbatim_doc_comment, value_name = "size")] )]
pub size: Vec<SizeFilter>, pub size: Vec<SizeFilter>,
/// Milliseconds to buffer before streaming search results to console /// Milliseconds to buffer before streaming search results to console
/// ///
@ -337,131 +396,153 @@ pub struct Opts {
#[arg(long, hide = true, value_parser = parse_millis)] #[arg(long, hide = true, value_parser = parse_millis)]
pub max_buffer_time: Option<Duration>, pub max_buffer_time: Option<Duration>,
/// Filter by file modification time (newer than) /// Filter by file modification time (newer than)
///
/// The argument can be provided as a specific point in time (YYYY-MM-DD HH:MM:SS)
/// or as a duration (10h, 1d, 35min).
/// If the time is not specified, it defaults to 00:00:00.
/// '--change-newer-than' or '--newer' can be used as aliases.
/// Examples:
/// --changed-within 2weeks
/// --change-newer-than '2018-10-27 10:00:00'
/// --newer 2018-10-27
#[arg( #[arg(
long, long,
alias("change-newer-than"), alias("change-newer-than"),
alias("newer"), alias("newer"),
value_name = "date|dur", value_name = "date|dur",
verbatim_doc_comment long_help = "Filter results based on the file modification time. The argument can be provided \
as a specific point in time (YYYY-MM-DD HH:MM:SS) or as a duration (10h, 1d, 35min). \
If the time is not specified, it defaults to 00:00:00. \
'--change-newer-than' or '--newer' can be used as aliases.\n\
Examples:\n \
--changed-within 2weeks\n \
--change-newer-than '2018-10-27 10:00:00'\n \
--newer 2018-10-27"
)] )]
pub changed_within: Option<String>, pub changed_within: Option<String>,
/// Filter by file modification time (older than) /// Filter by file modification time (older than)
///
/// The argument can be provided as a specific point in time (YYYY-MM-DD HH:MM:SS)
/// or as a duration (10h, 1d, 35min).
/// '--change-older-than' or '--older' can be used as aliases.
///
/// Examples:
/// --changed-before '2018-10-27 10:00:00'
/// --change-older-than 2weeks
/// --older 2018-10-27
#[arg( #[arg(
long, long,
alias("change-older-than"), alias("change-older-than"),
alias("older"), alias("older"),
value_name = "date|dur", value_name = "date|dur",
verbatim_doc_comment long_help = "Filter results based on the file modification time. The argument can be provided \
as a specific point in time (YYYY-MM-DD HH:MM:SS) or as a duration (10h, 1d, 35min). \
'--change-older-than' or '--older' can be used as aliases.\n\
Examples:\n \
--changed-before '2018-10-27 10:00:00'\n \
--change-older-than 2weeks\n \
--older 2018-10-27"
)] )]
pub changed_before: Option<String>, pub changed_before: Option<String>,
/// Limit number of search results /// Limit number of search results
/// #[arg(
/// Limit the number of search results to 'count' and quit immediately. long,
#[arg(long, value_name = "count", hide_short_help = true)] value_name = "count",
hide_short_help = true,
long_help = "Limit the number of search results to 'count' and quit immediately."
)]
max_results: Option<usize>, max_results: Option<usize>,
/// Limit search to a single result and quit immediately /// Limit search to a single result
/// #[arg(
/// This is an alias for '--max-results=1'. short = '1',
#[arg(short = '1', hide_short_help = true, overrides_with("max_results"))] hide_short_help = true,
overrides_with("max_results"),
long_help = "Limit the search to a single result and quit immediately. \
This is an alias for '--max-results=1'."
)]
max_one_result: bool, max_one_result: bool,
/// Print nothing, exit code 0 if match found, 1 otherwise /// Print nothing, exit code 0 if match found, 1 otherwise
///
/// When the flag is present, the program does not print anything and will
/// return with an exit code of 0 if there is at least one match. Otherwise, the
/// exit code will be 1.
///
/// '--has-results' can be used as an alias.
#[arg( #[arg(
long, long,
short = 'q', short = 'q',
alias = "has-results", alias = "has-results",
hide_short_help = true, hide_short_help = true,
conflicts_with("max_results") conflicts_with("max_results"),
long_help = "When the flag is present, the program does not print anything and will \
return with an exit code of 0 if there is at least one match. Otherwise, the \
exit code will be 1. \
'--has-results' can be used as an alias."
)] )]
pub quiet: bool, pub quiet: bool,
/// Show filesystem errors /// Show filesystem errors
/// #[arg(
///Enable the display of filesystem errors for situations such as long,
///insufficient permissions or dead symlinks. hide_short_help = true,
#[arg(long, hide_short_help = true)] long_help = "Enable the display of filesystem errors for situations such as \
insufficient permissions or dead symlinks."
)]
pub show_errors: bool, pub show_errors: bool,
/// Change the current working directory of fd to the provided path. This /// Change current working directory
/// means that search results will be shown with respect to the given base #[arg(
/// path. Note that relative paths which are passed to fd via the positional long,
/// <path> argument or the '--search-path' option will also be resolved value_name = "path",
/// relative to this directory. hide_short_help = true,
#[arg(long, value_name = "path", hide_short_help = true)] long_help = "Change the current working directory of fd to the provided path. This \
means that search results will be shown with respect to the given base \
path. Note that relative paths which are passed to fd via the positional \
<path> argument or the '--search-path' option will also be resolved \
relative to this directory."
)]
pub base_directory: Option<PathBuf>, pub base_directory: Option<PathBuf>,
/// the search pattern (a regular expression, unless '--glob' is used; optional) /// the search pattern (a regular expression, unless '--glob' is used; optional)
/// #[arg(
/// the search pattern which is either a regular expression (default) or a glob default_value = "",
/// pattern (if --glob is used). If no pattern has been specified, every entry hide_default_value = true,
/// is considered a match. If your pattern starts with a dash (-), make sure to value_name = "pattern",
/// pass '--' first, or it will be considered as a flag (fd -- '-foo'). long_help = "the search pattern which is either a regular expression (default) or a glob \
#[arg(default_value = "", hide_default_value = true)] pattern (if --glob is used). If no pattern has been specified, every entry \
is considered a match. If your pattern starts with a dash (-), make sure to \
pass '--' first, or it will be considered as a flag (fd -- '-foo')."
)]
pub pattern: String, pub pattern: String,
/// Set path separator when printing file paths /// Set path separator when printing file paths
/// Set the path separator to use when printing file paths. The default is #[arg(
/// the OS-specific separator ('/' on Unix, '\\' on Windows). long,
#[arg(long, value_name = "separator", hide_short_help = true)] value_name = "separator",
hide_short_help = true,
long_help = "Set the path separator to use when printing file paths. The default is \
the OS-specific separator ('/' on Unix, '\\' on Windows)."
)]
pub path_separator: Option<String>, pub path_separator: Option<String>,
/// the root directories for the filesystem search (optional) /// the root directories for the filesystem search (optional)
/// #[arg(action = ArgAction::Append,
/// The directories where the filesystem search is rooted. value_name = "path",
/// If omitted, search the current working directory. long_help = "The directory where the filesystem search is rooted (optional). If \
#[arg(action = ArgAction::Append)] omitted, search the current working directory.",
)]
path: Vec<PathBuf>, path: Vec<PathBuf>,
/// Provides paths to search as an alternative to the positional <path> argument /// Provides paths to search as an alternative to the positional <path> argument
/// #[arg(
/// Changes the usage to `fd [OPTIONS] --search-path <path> --search-path <path2> [<pattern>]` long,
#[arg(long, conflicts_with("path"), hide_short_help = true)] conflicts_with("path"),
value_name = "search-path",
hide_short_help = true,
long_help = "Provide paths to search as an alternative to the positional <path> \
argument. Changes the usage to `fd [OPTIONS] --search-path <path> \
--search-path <path2> [<pattern>]`"
)]
search_path: Vec<PathBuf>, search_path: Vec<PathBuf>,
/// strip './' prefix from -0/--print-0 output
///
/// By default, relative paths are prefixed with './' when -x/--exec, /// By default, relative paths are prefixed with './' when -x/--exec,
/// -X/--exec-batch, or -0/--print0 are given, to reduce the risk of a /// -X/--exec-batch, or -0/--print0 are given, to reduce the risk of a
/// path starting with '-' being treated as a command line option. Use /// path starting with '-' being treated as a command line option. Use
/// this flag to disable this behaviour. /// this flag to disable this behaviour.
#[arg(long, conflicts_with_all(&["path", "search_path"]), hide_short_help = true)] #[arg(long, conflicts_with_all(&["path", "search_path"]), hide_short_help = true,
long_help = "By default, relative paths are prefixed with './' when -x/--exec, \
-X/--exec-batch, or -0/--print0 are given, to reduce the risk of a \
path starting with '-' being treated as a command line option. Use \
this flag to disable this behaviour.",
)]
pub strip_cwd_prefix: bool, pub strip_cwd_prefix: bool,
/// Filter by owning user and/or group /// Filter by owning user and/or group
///
/// Format: [(user|uid)][:(group|gid)].
/// Either side is optional. Precede either side with a '!' to exclude files instead.
///
/// Examples:
/// --owner john
/// --owner :students
/// --owner '!john:students'
#[cfg(unix)] #[cfg(unix)]
#[arg(long, short = 'o', value_parser = OwnerFilter::from_string, value_name = "user:group", verbatim_doc_comment)] #[arg(long, short = 'o', value_parser = OwnerFilter::from_string, value_name = "user:group",
long_help = "Filter files by their user and/or group. \
Format: [(user|uid)][:(group|gid)]. Either side is optional. \
Precede either side with a '!' to exclude files instead.\n\
Examples:\n \
--owner john\n \
--owner :students\n \
--owner '!john:students'"
)]
pub owner: Option<OwnerFilter>, pub owner: Option<OwnerFilter>,
/// Do not descend into a different file system
///
/// By default, fd will traverse the file system tree as far as other options
/// dictate. With this flag, fd ensures that it does not descend into a
/// different file system than the one it started in. Comparable to the -mount
/// or -xdev filters of find(1).
#[cfg(any(unix, windows))] #[cfg(any(unix, windows))]
#[arg(long, aliases(&["mount", "xdev"]), hide_short_help = true)] #[arg(long, aliases(&["mount", "xdev"]), hide_short_help = true,
long_help = "By default, fd will traverse the file system tree as far as other options \
dictate. With this flag, fd ensures that it does not descend into a \
different file system than the one it started in. Comparable to the -mount \
or -xdev filters of find(1).")]
pub one_file_system: bool, pub one_file_system: bool,
#[cfg(feature = "completions")] #[cfg(feature = "completions")]
@ -609,8 +690,8 @@ impl ColorWhen {
use ColorWhen::*; use ColorWhen::*;
match *self { match *self {
Auto => "auto", Auto => "auto",
Always => "always",
Never => "never", Never => "never",
Always => "always",
} }
} }
} }