Added some more gamenight-cli Flows.

This commit is contained in:
2025-05-02 22:58:45 +02:00
parent db25dc0aed
commit 6699dcf392
11 changed files with 309 additions and 66 deletions

View File

@@ -1,8 +1,12 @@
use gamenight_api_client_rs::apis::default_api::get_gamenights;
use inquire::Select;
use super::*;
use crate::flows::view_gamenight::ViewGamenight;
use super::{abort::Abort, *};
#[derive(Clone)]
pub struct ListGamenights {
}
@@ -17,8 +21,16 @@ impl ListGamenights {
impl<'a> Flow<'a> for ListGamenights {
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
let response = get_gamenights(&state.configuration).await?;
println!("{:?}", response);
Ok((FlowOutcome::Successful, state))
let mut view_flows = response.into_iter().map(|gamenight| -> Box<dyn Flow<'a> + Send> {
Box::new(ViewGamenight::new(gamenight))
}).collect::<Vec<Box<dyn Flow<'a> + Send>>>();
view_flows.push(Box::new(Abort::new()));
let choice = Select::new("What gamenight would you like to view?", view_flows)
.prompt_skippable()?;
handle_choice_option(&choice, self, state).await
}
}