Fixed warnings from cargo
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
use std::{collections::HashMap, io::Write};
|
||||
|
||||
|
||||
|
||||
pub(crate) fn simple_prompt(p: &str) -> String {
|
||||
|
||||
print!("{c}prompt{r}: {p} > ",
|
||||
c=anstyle::AnsiColor::Cyan.render_fg(),
|
||||
r=anstyle::Reset.render()
|
||||
);
|
||||
|
||||
// I dont care if it fails
|
||||
let _ = std::io::stdout().flush();
|
||||
|
||||
let mut buf = String::new();
|
||||
let _ = std::io::stdin().read_line(&mut buf);
|
||||
|
||||
buf.trim().to_string()
|
||||
}
|
||||
//pub(crate) fn simple_prompt(p: &str) -> String {
|
||||
//
|
||||
// print!("{c}prompt{r}: {p} > ",
|
||||
// c=anstyle::AnsiColor::Cyan.render_fg(),
|
||||
// r=anstyle::Reset.render()
|
||||
// );
|
||||
//
|
||||
// // I dont care if it fails
|
||||
// let _ = std::io::stdout().flush();
|
||||
//
|
||||
// let mut buf = String::new();
|
||||
// let _ = std::io::stdin().read_line(&mut buf);
|
||||
//
|
||||
// buf.trim().to_string()
|
||||
//}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize {
|
||||
@@ -47,33 +46,33 @@ pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn prompt_with_list_or_str(p: &str, options: &[String]) -> String {
|
||||
println!("{c}prompt{r}: {p} (select with number or input text)",
|
||||
c=anstyle::AnsiColor::Cyan.render_fg(),
|
||||
r=anstyle::Reset.render()
|
||||
);
|
||||
|
||||
for (i, op) in options.iter().enumerate() {
|
||||
println!(" - {}: {}", i, op);
|
||||
}
|
||||
|
||||
print!("> ");
|
||||
// I dont care if it fails
|
||||
let _ = std::io::stdout().flush();
|
||||
|
||||
let mut buf = String::new();
|
||||
let _ = std::io::stdin().read_line(&mut buf);
|
||||
|
||||
if let Ok(num) = buf.trim().parse::<usize>() {
|
||||
if let Some(g) = options.get(num) {
|
||||
return g.clone();
|
||||
} else {
|
||||
return prompt_with_list_or_str(p, options);
|
||||
}
|
||||
} else {
|
||||
return buf.trim().to_string();
|
||||
}
|
||||
}
|
||||
// pub(crate) fn prompt_with_list_or_str(p: &str, options: &[String]) -> String {
|
||||
// println!("{c}prompt{r}: {p} (select with number or input text)",
|
||||
// c=anstyle::AnsiColor::Cyan.render_fg(),
|
||||
// r=anstyle::Reset.render()
|
||||
// );
|
||||
//
|
||||
// for (i, op) in options.iter().enumerate() {
|
||||
// println!(" - {}: {}", i, op);
|
||||
// }
|
||||
//
|
||||
// print!("> ");
|
||||
// // I dont care if it fails
|
||||
// let _ = std::io::stdout().flush();
|
||||
//
|
||||
// let mut buf = String::new();
|
||||
// let _ = std::io::stdin().read_line(&mut buf);
|
||||
//
|
||||
// if let Ok(num) = buf.trim().parse::<usize>() {
|
||||
// if let Some(g) = options.get(num) {
|
||||
// return g.clone();
|
||||
// } else {
|
||||
// return prompt_with_list_or_str(p, options);
|
||||
// }
|
||||
// } else {
|
||||
// return buf.trim().to_string();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
||||
Reference in New Issue
Block a user