2024-08-11 23:25:25 +00:00
|
|
|
#![allow(missing_docs)]
|
2024-01-16 02:44:48 +00:00
|
|
|
|
2025-02-22 10:29:49 +00:00
|
|
|
use keyfork_prompt::default_handler;
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
|
|
|
pub enum Choices {
|
|
|
|
Retry,
|
|
|
|
Continue,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Choices {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
Choices::Retry => write!(
|
|
|
|
f,
|
|
|
|
"Retry with some really long text that I want to cause issues with."
|
|
|
|
),
|
|
|
|
Choices::Continue => write!(
|
|
|
|
f,
|
|
|
|
"Continue with some really long text that I want to cause issues with."
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl keyfork_prompt::Choice for Choices {
|
|
|
|
fn identifier(&self) -> Option<char> {
|
|
|
|
Some(match self {
|
|
|
|
Choices::Retry => 'r',
|
|
|
|
Choices::Continue => 'c',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2023-12-21 17:04:35 +00:00
|
|
|
|
2024-01-07 04:23:41 +00:00
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2025-01-30 17:10:36 +00:00
|
|
|
let mut handler = default_handler()?;
|
2024-01-10 20:13:42 +00:00
|
|
|
|
2025-02-22 10:29:49 +00:00
|
|
|
let choice = keyfork_prompt::prompt_choice(
|
|
|
|
&mut *handler,
|
|
|
|
"Here are some options!",
|
|
|
|
&[Choices::Retry, Choices::Continue],
|
|
|
|
);
|
|
|
|
|
|
|
|
dbg!(&choice);
|
2024-01-10 20:13:42 +00:00
|
|
|
|
2023-12-21 17:04:35 +00:00
|
|
|
Ok(())
|
|
|
|
}
|