🍺 Run —
Run
is a command-line tool that executes commands in multiple directories
concurrently.
Command: | Time: |
---|---|
find -iname .git -execdir ls \; |
real 0m17.340s user 0m6.214s sys 0m9.138s |
Run -P .git -C ls |
real 0m8.480s user 0m0.046s sys 0m0.046s |
find -iname .git -execdir git status \; |
real 1m19.070s user 0m5.385s sys 0m7.357s |
Run -P .git -C 'git status' |
real 0m26.170s user 0m0.030s sys 0m0.046s |
cargo install prun
Run
can be used with various options:
🍺 Run —
Usage: Run [OPTIONS] --Command <COMMAND> <PATTERN>
Arguments:
<PATTERN> 🔍 Pattern — [default: .]
Options:
-F, --File 📝 File —
-P, --Parallel ⏩ Parallel —
-R, --Root <ROOT> 📂 Root — [default: .]
-E, --Exclude <EXCLUDE> 🚫 Exclude — [default: "node_modules .git target dist vendor"]
-C, --Command <COMMAND> 🖥️ Command —
-h, --help Print help
-V, --version Print version
Run .git -C 'git fetch upstream'
This command will fetch from upstream for all .git
repositories inside the
current directory. It essentially replaces the following command:
find -iname .git -type d -execdir git fetch upstream \;
The command to execute:
Run .git -C 'git status'
or multiple commands:
Run .git -C 'git status' -C 'git add .' -C 'git commit'
Limit execution to files matching a certain pattern:
Run -F astro.config.ts -C 'npx astro add @playform/compress'
Set the current working directory to a different folder (default is .
):
Run -R D:\Developer .git -C 'git fetch upstream'
Run commands in parallel
(default is sequential
):
Run -P -R D:\Developer .git -C 'git fetch upstream'
Exclude certain files or directories (defailt is
node_modules .git target dist vendor
)
Specify a custom pattern for matching
Run
relies on several Rust crates to provide its functionality:
-
clap (v4.5.17) - A powerful and flexible command-line argument parser. The "derive" feature is used to simplify the creation of command-line interfaces through derive macros.
-
walkdir (v2.5.0) - Provides an efficient and cross-platform way to recursively traverse directories. This is useful for filesystem operations and searching.
-
futures (v0.3.30) - Offers abstractions for asynchronous programming in Rust. It's used in conjunction with tokio to handle asynchronous operations effectively.
-
rayon (v1.10.0) - Enables easy parallelism for data-parallel tasks. It's used to parallelize CPU-bound operations, improving performance on multi-core systems.
-
tokio (v1.40.0) - An asynchronous runtime for Rust, providing essential building blocks for writing reliable asynchronous applications. The "full" feature set is used to enable all tokio functionality.
-
num_cpus (v1.16.0) - A small crate that determines the number of CPUs on the current system. This is useful for optimizing parallel workloads.
-
once_cell (v1.19.0) - Provides a way to perform lazy static initialization. It's often used for global variables or singletons that need to be initialized only once.
These dependencies work together to provide a robust, efficient, and user-friendly command-line tool capable of handling parallel and asynchronous operations while efficiently traversing filesystems.
See CHANGELOG.md for a history of changes to this CLI.