diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-09-02 21:58:32 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-09-02 21:58:32 +0200 |
commit | 2fec5e4509aeb4520691bce57016707a399dffa6 (patch) | |
tree | 35e4c5b26bee2a0f99e982f790d9460f57d62525 /planetwars-client/src | |
parent | d95eedcc83f8d07a49c25c5240beb8a0105d877a (diff) | |
download | planetwars.dev-2fec5e4509aeb4520691bce57016707a399dffa6.tar.xz planetwars.dev-2fec5e4509aeb4520691bce57016707a399dffa6.zip |
implement map selection in cli
Diffstat (limited to 'planetwars-client/src')
-rw-r--r-- | planetwars-client/src/main.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/planetwars-client/src/main.rs b/planetwars-client/src/main.rs index 21da005..1821fd3 100644 --- a/planetwars-client/src/main.rs +++ b/planetwars-client/src/main.rs @@ -22,6 +22,9 @@ struct PlayMatch { #[clap(value_parser)] opponent_name: String, + #[clap(value_parser, long = "map")] + map_name: Option<String>, + #[clap( value_parser, long, @@ -69,9 +72,13 @@ async fn main() { let channel = Channel::builder(uri).connect().await.unwrap(); - let created_match = create_match(channel.clone(), play_match.opponent_name) - .await - .unwrap(); + let created_match = create_match( + channel.clone(), + play_match.opponent_name, + play_match.map_name, + ) + .await + .unwrap(); run_player(bot_config, created_match.player_key, channel).await; println!( "Match completed. Watch the replay at {}", @@ -83,10 +90,14 @@ async fn main() { async fn create_match( channel: Channel, opponent_name: String, + map_name: Option<String>, ) -> Result<pb::CreateMatchResponse, Status> { let mut client = ClientApiServiceClient::new(channel); let res = client - .create_match(Request::new(pb::CreateMatchRequest { opponent_name })) + .create_match(Request::new(pb::CreateMatchRequest { + opponent_name, + map_name: map_name.unwrap_or_default(), + })) .await; res.map(|response| response.into_inner()) } |