-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
1,840 additions
and
603 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::io::{Error, ErrorKind}; | ||
|
||
use clap::{Arg, Command}; | ||
use mahjong_service::db_storage::DBStorage; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct PrintGameOpts { | ||
pub game_id: String, | ||
} | ||
|
||
pub async fn print_game(opts: PrintGameOpts) -> Result<(), Error> { | ||
let storage = DBStorage::new_dyn(); | ||
|
||
let game = storage | ||
.get_game(&opts.game_id, false) | ||
.await | ||
.unwrap() | ||
.ok_or_else(|| { | ||
Error::new( | ||
ErrorKind::Other, | ||
format!("Game with ID {} not found", opts.game_id), | ||
) | ||
})?; | ||
|
||
println!("Game:\n{}", game.game.get_summary_sorted()); | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn get_print_game_command() -> Command { | ||
Command::new("print-game") | ||
.about("Print the game summary") | ||
.arg( | ||
Arg::new("game-id") | ||
.short('i') | ||
.help("The ID of the game to print"), | ||
) | ||
} | ||
|
||
pub fn get_print_game_opts(matches: &clap::ArgMatches) -> PrintGameOpts { | ||
let game_id: &String = matches.get_one("game-id").unwrap(); | ||
|
||
PrintGameOpts { | ||
game_id: game_id.clone(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.