-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.rs
38 lines (32 loc) · 979 Bytes
/
options.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! # Demonstration of configuration options
//!
//! This blocking example demonstrates some of the configuration options available to the picker.
use std::io::Result;
use nucleo_picker::{nucleo::Config, render::StrRenderer, PickerOptions};
fn main() -> Result<()> {
let mut picker = PickerOptions::default()
// set the configuration to match 'path-like' objects
.config(Config::DEFAULT.match_paths())
// set the default prompt to `/var`
.query("/var")
.picker(StrRenderer);
let choices = vec![
"/var/tmp",
"/var",
"/usr/local",
"/usr",
"/usr/local/share",
"/dev",
];
// populate the matcher
let injector = picker.injector();
for opt in choices {
injector.push(opt);
}
// open interactive prompt
match picker.pick()? {
Some(opt) => println!("You selected: '{opt}'"),
None => println!("Nothing selected!"),
}
Ok(())
}