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

@@ -0,0 +1,44 @@
use gamenight_api_client_rs::{apis::default_api::post_gamenight, models};
use inquire::{Text, DateSelect};
use chrono::{self, Local, NaiveTime};
use super::*;
#[derive(Clone)]
pub struct AddGamenight {
}
impl AddGamenight {
pub fn new() -> Self {
Self {}
}
}
#[async_trait]
impl<'a> Flow<'a> for AddGamenight {
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
let mut add_gamenight = models::AddGamenightRequestBody::new();
add_gamenight.name = Some(Text::new("What should we call your gamenight").prompt()?);
add_gamenight.datetime = Some(DateSelect::new("When is your gamenight").prompt()?
.and_time(NaiveTime::default())
.and_local_timezone(Local)
.earliest()
.unwrap()
.to_utc()
.to_rfc3339());
post_gamenight(&state.configuration, Some(add_gamenight)).await?;
Ok((FlowOutcome::Successful, state))
}
}
impl Display for AddGamenight {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Add Gamenight.")
}
}