diff options
author | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
commit | a990de90fe41456a23e58bd087d2f107d321f3a1 (patch) | |
tree | 15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/dialoguer/examples/completion.rs | |
parent | 3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff) | |
download | fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip |
Deleted vendor folder
Diffstat (limited to 'vendor/dialoguer/examples/completion.rs')
-rw-r--r-- | vendor/dialoguer/examples/completion.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/vendor/dialoguer/examples/completion.rs b/vendor/dialoguer/examples/completion.rs deleted file mode 100644 index 76d790b..0000000 --- a/vendor/dialoguer/examples/completion.rs +++ /dev/null @@ -1,44 +0,0 @@ -use dialoguer::{theme::ColorfulTheme, Completion, Input}; - -fn main() -> Result<(), std::io::Error> { - println!("Use the Right arrow or Tab to complete your command"); - let completion = MyCompletion::default(); - Input::<String>::with_theme(&ColorfulTheme::default()) - .with_prompt("dialoguer") - .completion_with(&completion) - .interact_text()?; - Ok(()) -} - -struct MyCompletion { - options: Vec<String>, -} - -impl Default for MyCompletion { - fn default() -> Self { - MyCompletion { - options: vec![ - "orange".to_string(), - "apple".to_string(), - "banana".to_string(), - ], - } - } -} - -impl Completion for MyCompletion { - /// Simple completion implementation based on substring - fn get(&self, input: &str) -> Option<String> { - let matches = self - .options - .iter() - .filter(|option| option.starts_with(input)) - .collect::<Vec<_>>(); - - if matches.len() == 1 { - Some(matches[0].to_string()) - } else { - None - } - } -} |