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
Provenance
- Commit
b5344da- Tree
56ebef4- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
018556a
2 files changed+75 added−19 removed
modified:doc/fd.1+49 added-5 removed
257 unmodified lines258 Provide 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+.RS263 Execute264 .I command264-for 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:265+for each search result in parallel (use --threads=1 for sequential command execution).266+267+Note that all subsequent positional arguments are considered to be arguments to the268+.I command269+- not to fd.270+It is therefore recommended to place the \-x/\-\-exec option last. Alternatively, you can supply271+a ';' argument to end the argument list and continue with more fd options.272+Most shells require ';' to be escaped: '\\;'.273+274+The following placeholders are substituted before the command is executed:275 .RS276 .IP {}267-path277+path (of the current search result)278 .IP {/}279 basename280 .IP {//}281 parent directory1 unmodified line283 path without file extension284 .IP {/.}285 basename without file extension286 .RE287+288+If no placeholder is present, an implicit "{}" at the end is assumed.289+290+Examples:291+292+ - find all *.zip files and unzip them:293+294+ fd -e zip -x unzip295+296+ - find *.h and *.cpp files and run "clang-format -i .." for each of them:297+298+ fd -e h -e cpp -x clang-format -i299+300+ - Convert all *.jpg files to *.png files:301+302+ fd -e jpg -x convert {} {.}.png303+.RE304 .TP305 .BI "\-X, \-\-exec-batch " command306+.RS307 Execute308 .I command281-with all search results at once.282-A single occurence of the following placeholders is authorized and substituted by the paths derived from the search results before the command is executed:309+once, with all search results as arguments.310+One of the following placeholders is substituted before the command is executed:311 .RS312 .IP {}285-path313+path (of all search results)314 .IP {/}315 basename316 .IP {//}317 parent directory1 unmodified line319 path without file extension320 .IP {/.}321 basename without file extension322 .RE323+324+If no placeholder is present, an implicit "{}" at the end is assumed.325+326+Examples:327+328+ - Find all test_*.py files and open them in your favorite editor:329+330+ fd -g 'test_*.py' -X vim331+332+ Note that this executes a single "vim" process with all search results as arguments.333+334+ - Find all *.rs files and count the lines with "wc -l ...":335+336+ fd -e rs -X wc -l337+.RE338+339 .SH PATTERN SYNTAX340 The regular expression syntax used by fd is documented here:341 342 https://docs.rs/regex/1.0.0/regex/#syntax35 unmodified linesmodified:src/app.rs+26 added-14 removed
296 unmodified lines297 .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 lines328 .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