Crates.io | fuzzypicker |
lib.rs | fuzzypicker |
version | 0.2.1 |
source | src |
created_at | 2024-07-08 16:06:53.907162 |
updated_at | 2024-07-12 20:29:12.628702 |
description | A Rust library for fuzzy searching and interactive selection of items in command-line applications. |
homepage | https://lib.rs/fuzzypicker |
repository | https://github.com/galib45/fuzzypicker |
max_upload_size | |
id | 1296119 |
size | 15,761 |
Fuzzypicker is a Rust library for enabling fuzzy searching and interactive selection of items in command-line applications. It is designed to assist in building CLI tools where users need to select an item from a list based on fuzzy matching criteria.
Add fuzzypicker to your project
cargo add fuzzypicker
Here's a basic example demonstrating how to use fuzzypicker to implement a fuzzy selection mechanism in a Rust CLI application:
use fuzzypicker::FuzzyPicker;
fn main() {
// Example list of items (could be anything implementing Display + Clone)
let items = vec![
"apple", "banana", "cherry", "date", "elderberry", "fig", "grape", "honeydew",
];
// Create a new FuzzyPicker instance
let mut picker = FuzzyPicker::new(&items);
// Perform interactive selection
if let Ok(Some(selected_item)) = picker.pick() {
println!("Selected item: {}", selected_item);
} else {
println!("Selection cancelled or no item selected.");
}
}
struct FuzzyPicker<T: Display + Clone>
new(items: &[T]) -> Self
: Constructs a new FuzzyPicker
instance with a list of items.pick() -> Result<Option<T>, Box<dyn Error>>
: Initiates the interactive selection process. Returns Some(selected_item) if an item is selected, or None if selection is cancelled.Contributions are welcome! If you'd like to contribute to fuzzypicker
, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.