4 stable releases
new 2.0.1 | Apr 15, 2025 |
---|---|
1.1.0 | Jan 16, 2025 |
1.0.1 | Nov 4, 2024 |
#1387 in Command line utilities
119 downloads per month
37KB
222 lines
superwhich
superwhich
is a cross-platform CLI tool and library that was initially meant to be a faster drop-in replacement for Windows' where
command but since it uses Jaro-Winkler distance to calculate the similarity between the strings it can be called a sort of "smart" which, it can handle some typos and highlights the section of the executables that matches the search pattern.
Installation
CLI
- From crates.io:
cargo install superwhich
- From GitHub:
cargo install --git https://github.com/DarkCeptor44/superwhich
- Manually (after cloning the repo locally):
cargo install --path .
- From releases.
Library
cargo add superwhich
Or you can add this to your Cargo.toml
file:
[dependencies]
superwhich = "^2"
Usage
$ swhich -h
Cross-platform smart which alternative
Usage: swhich.exe [OPTIONS] <PATTERN>
Arguments:
<PATTERN> The search pattern
Options:
-c, --color <COLOR> Color of the highlighted text (off or set `NO_COLOR` env var to disable) [default: blue]
-T, --threshold <THRESHOLD> String similarity threshold (0.0 to 1.0) [default: 0.7]
-t, --print-time Print time elapsed
-h, --help Print help
-V, --version Print version
Todo
- Make it faster (currently at
~221ms
on Windows). - Find a better way to match the pattern to the name when printing the result so it highlights similar strings as well.
Tests
You can run the tests with cargo test
.
Benchmarks
Library
The library benchmarks can be ran with cargo bench
.
Benchmark | Min Mean Max | Outliers |
---|---|---|
find_executables/fake binaries |
73.288 µs 73.486 µs 73.725 µs | 4 (4.00%) high mild, 6 (6.00%) high severe |
find_executables/real PATH |
210.48 ms 211.14 ms 211.84 ms | 4 (4.00%) high mild, 1 (1.00%) high severe |
highlight_text |
1.4787 µs 1.4829 µs 1.4872 µs | 2 (2.00%) low mild, 1 (1.00%) high mild, 3 (3.00%) high severe |
CLI
The CLI was benchmarked using Hyperfine.
Windows
- AMD64, 32GB RAM, Ryzen 7 3800X, Windows 10.
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
where pnpm |
94.7 ± 1.1 | 93.5 | 98.7 | 1.00 |
swhich pnpm |
221.8 ± 3.5 | 215.7 | 229.2 | 2.34 ± 0.05 |
Linux
- ARM64, 1GB RAM, Orange Pi Zero2, Debian 12.
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
which lookfor |
3.0 ± 0.2 | 2.6 | 4.7 | 1.00 |
swhich lookfor |
17.6 ± 0.3 | 17.0 | 19.8 | 5.93 ± 0.43 |
License
This project is licensed under the terms of the GNU General Public License v3.0.
Dependencies
~2.4–9.5MB
~92K SLoC