Adds Adding of Games to the system.

This commit is contained in:
2025-06-27 22:08:23 +02:00
parent 3f51d52edf
commit 28f7306d57
40 changed files with 792 additions and 130 deletions

View File

@@ -0,0 +1,44 @@
use std::fmt::Display;
use async_trait::async_trait;
use gamenight_api_client_rs::{apis::default_api::game_post, models::{AddGameRequestBody, Game}};
use inquire::{Confirm, Text};
use super::*;
#[derive(Clone)]
pub struct AddGame {
}
impl AddGame {
pub fn new() -> Self {
Self {}
}
}
#[async_trait]
impl<'a> Flow<'a> for AddGame {
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
if let Some(name) = Text::new("What is the game you want to add").prompt_skippable()? {
let add_game_request = AddGameRequestBody {
name
};
game_post(&state.api_configuration, Some(add_game_request)).await?;
if let Some(owned) = Confirm::new("Do you own this game?").prompt_skippable()? {
if owned {
todo!()
}
}
}
Ok((FlowOutcome::Cancelled, state))
}
}
impl Display for AddGame {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Add Game")
}
}