forked from Roflin/gamenight
Adds Adding of Games to the system.
This commit is contained in:
44
gamenight-cli/src/flows/add_game.rs
Normal file
44
gamenight-cli/src/flows/add_game.rs
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user