Skip to content
Myr

Improve -x/-X help text and man page description

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #605

authored by David Peter · committed by David Peter · parent 018556a · Browse files · 2 files+75 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+75 added−19 removed

  • other:+75 added−19 removed

2 files+75 added−19 removed

modified:doc/fd.1+49 added-5 removed
257 unmodified lines
258Provide paths to search as an alternative to the positional \fIpath\fR argument. Changes the usage to259\'fd [FLAGS/OPTIONS] \-\-search\-path PATH \-\-search\-path PATH2 [PATTERN]\'260.TP261.BI "\-x, \-\-exec " command262.RS263Execute264.I command264for each search result in parallel (use --threads=1 for sequential command execution). The following placeholders are substituted by a path derived from the current search result:265for each search result in parallel (use --threads=1 for sequential command execution).266267Note that all subsequent positional arguments are considered to be arguments to the268.I command269- not to fd.270It is therefore recommended to place the \-x/\-\-exec option last. Alternatively, you can supply271a ';' argument to end the argument list and continue with more fd options.272Most shells require ';' to be escaped: '\\;'.273274The following placeholders are substituted before the command is executed:275.RS276.IP {}267path277path (of the current search result)278.IP {/}279basename280.IP {//}281parent directory
1 unmodified line
283path without file extension284.IP {/.}285basename without file extension286.RE287288If no placeholder is present, an implicit "{}" at the end is assumed.289290Examples:291292 - find all *.zip files and unzip them:293294 fd -e zip -x unzip295296 - find *.h and *.cpp files and run "clang-format -i .." for each of them:297298 fd -e h -e cpp -x clang-format -i299300 - Convert all *.jpg files to *.png files:301302 fd -e jpg -x convert {} {.}.png303.RE304.TP305.BI "\-X, \-\-exec-batch " command306.RS307Execute308.I command281with all search results at once.282A single occurence of the following placeholders is authorized and substituted by the paths derived from the search results before the command is executed:309once, with all search results as arguments.310One of the following placeholders is substituted before the command is executed:311.RS312.IP {}285path313path (of all search results)314.IP {/}315basename316.IP {//}317parent directory
1 unmodified line
319path without file extension320.IP {/.}321basename without file extension322.RE323324If no placeholder is present, an implicit "{}" at the end is assumed.325326Examples:327328 - Find all test_*.py files and open them in your favorite editor:329330 fd -g 'test_*.py' -X vim331332 Note that this executes a single "vim" process with all search results as arguments.333334 - Find all *.rs files and count the lines with "wc -l ...":335336 fd -e rs -X wc -l337.RE338339.SH PATTERN SYNTAX340The regular expression syntax used by fd is documented here:341342 https://docs.rs/regex/1.0.0/regex/#syntax
35 unmodified lines
modified:src/app.rs+26 added-14 removed
296 unmodified lines
297 .value_name("cmd")298 .conflicts_with("list-details")299 .help("Execute a command for each search result")300 .long_help(301 "Execute a command for each search result in parallel (use --threads=1 for sequential command execution).\n\302 All arguments following --exec are taken to be arguments to the command until the \303 argument ';' is encountered.\n\304 Each occurrence of the following placeholders is substituted by a path derived from the \305 current search result before the command is executed:\n \306 '{}': path\n \301 "Execute a command for each search result in parallel (use --threads=1 for sequential command execution). \302 All positional arguments following --exec are considered to be arguments to the command - not to fd. \303 It is therefore recommended to place the '-x'/'--exec' option last.\n\304 The following placeholders are substituted before the command is executed:\n \305 '{}': path (of the current search result)\n \306 '{/}': basename\n \307 '{//}': parent directory\n \308 '{.}': path without file extension\n \310 '{/.}': basename without file extension",309 '{/.}': basename without file extension\n\n\310 If no placeholder is present, an implicit \"{}\" at the end is assumed.\n\n\311 Examples:\n\n \312 - find all *.zip files and unzip them:\n\n \313 fd -e zip -x unzip\n\n \314 - find *.h and *.cpp files and run \"clang-format -i ..\" for each of them:\n\n \315 fd -e h -e cpp -x clang-format -i\n\n \316 - Convert all *.jpg files to *.png files:\n\n \317 fd -e jpg -x convert {} {.}.png\318 ",319 ),320 )321 .arg(322 Arg::with_name("exec-batch")
5 unmodified lines
328 .value_name("cmd")329 .conflicts_with_all(&["exec", "list-details"])330 .help("Execute a command with all search results at once")331 .long_help(324 "Execute a command with all search results at once.\n\325 All arguments following --exec-batch are taken to be arguments to the command until the \326 argument ';' is encountered.\n\327 A single occurrence of the following placeholders is authorized and substituted by the paths derived from the \328 search results before the command is executed:\n \329 '{}': path\n \332 "Execute the given command once, with all search results as arguments.\n\333 One of the following placeholders is substituted before the command is executed:\n \334 '{}': path (of all search results)\n \335 '{/}': basename\n \336 '{//}': parent directory\n \337 '{.}': path without file extension\n \333 '{/.}': basename without file extension",338 '{/.}': basename without file extension\n\n\339 If no placeholder is present, an implicit \"{}\" at the end is assumed.\n\n\340 Examples:\n\n \341 - Find all test_*.py files and open them in your favorite editor:\n\n \342 fd -g 'test_*.py' -X vim\n\n \343 - Find all *.rs files and count the lines with \"wc -l ...\":\n\n \344 fd -e rs -X wc -l\345 "346 ),347 )348 .arg(349 Arg::with_name("exclude")
266 unmodified lines