Crate superwhich

Crate superwhich 

Source
Expand description

§superwhich

Smart which alternative

§Installation

cargo add superwhich

Or add this to your Cargo.toml file:

[dependencies]
superwhich = "^2"

§Usage

use is_executable::IsExecutable;
use std::{
    collections::BTreeSet,
    env::{split_paths, var_os},
    path::PathBuf,
};
use superwhich::find_executables;

let paths: Vec<PathBuf> = split_paths(&var_os("PATH").expect("PATH is not set")).collect();

// finds executables in the paths provided that match the pattern,
// while `is_executable` crate is used in the CLI you can also just use a
// closure that returns true or false
let found: BTreeSet<PathBuf> = find_executables(&paths, "pattern", 0.7, IsExecutable::is_executable);

Refer to the README for more details.

Functions§

find_executables
Find executables within the specified paths that match the pattern
highlight_text
Highlight the specified text with the specified color