8 releases
0.1.3 | Sep 17, 2024 |
---|---|
0.1.2 | Sep 17, 2024 |
0.1.0 | Jul 31, 2024 |
0.0.7 | Jul 25, 2024 |
0.0.5 | Apr 19, 2024 |
#365 in Filesystem
403 downloads per month
24KB
368 lines
πΊβRunββ
Run
is a command-line tool that executes commands in multiple directories
concurrently.
Bench
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 |
π Installation
cargo install prun
π οΈ Usage
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 \;
Options
--Command or -C:
The command to execute:
Run .git -C 'git status'
or multiple commands:
Run .git -C 'git status' -C 'git add .' -C 'git commit'
--File or -F:
Limit execution to files matching a certain pattern:
Run -F astro.config.ts -C 'npx astro add @playform/compress'
--Root or -R:
Set the current working directory to a different folder (default is .
):
Run -R D:\Developer .git -C 'git fetch upstream'
--Parallel or -P:
Run commands in parallel
(default is sequential
):
Run -P -R D:\Developer .git -C 'git fetch upstream'
--Exclude:
Exclude certain files or directories (defailt is
node_modules .git target dist vendor
)
--Pattern:
Specify a custom pattern for matching
Dependencies
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.
Changelog
See CHANGELOG.md for a history of changes to this CLI.
Dependencies
~5β15MB
~173K SLoC