Something went wrong. Try again.
🧑🍳 cli for writing, generating, and saving recipes
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869use inquire::Select;use std::fmt;mod chatbot;mod cookbook;mod read_cookbook;mod utils;mod write_recipe;use ctrlc;use std::sync::atomic::{AtomicBool, Ordering};use std::sync::Arc;
enum Choice { Cookbook, Chatbot, NewRecipe,}
impl fmt::Display for Choice { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Choice::Chatbot => write!(f, "From some chatbot"), Choice::Cookbook => write!(f, "From the cookbook"), Choice::NewRecipe => write!(f, "I'm gonna write a recipe myself"), } }}
#[tokio::main]async fn main() { let running = Arc::new(AtomicBool::new(true)); let r = running.clone();
ctrlc::set_handler(move || { println!("Received Ctrl+C, exiting..."); r.store(false, Ordering::SeqCst); }) .expect("Error setting Ctrl+C handler");
while running.load(Ordering::SeqCst) { let options = vec![Choice::Cookbook, Choice::Chatbot, Choice::NewRecipe];
let choice = Select::new("What would you like to cook up today?", options).prompt();
match choice { Ok(selection) => match selection { Choice::Cookbook => { cookbook::cookbook(); } Choice::Chatbot => { chatbot::chatbot().await; } Choice::NewRecipe => { write_recipe::recipes(); } }, Err(inquire::error::InquireError::OperationInterrupted) => { println!("Goodbye!"); break; } Err(err) => { eprintln!("Error: {:?}", err); break; } }
break; }}