@@ -14,7 +14,7 @@ use tokio::{
1414use wasmer_cache:: { Cache , FileSystemCache } ;
1515use wasi_process2:: WasiProcess ;
1616use wasmer_wasi:: { WasiFunctionEnv , WasiVersion , WasiEnv } ;
17- use wasmer:: { AsStoreMut , AsStoreRef , Instance , FunctionEnv } ;
17+ use wasmer:: AsStoreMut ;
1818
1919use logic:: { GameMode , MainOutput , RobotRunner } ;
2020
@@ -72,6 +72,9 @@ enum Run {
7272 /// It will then start receiving newline-delimited `ProgramInput` json object. It must respond to
7373 /// each one with a `ProgramOutput` json object followed by a newline. The match is over when stdin is closed, and
7474 /// the process may be forcefully terminated after that.
75+ ///
76+ /// Please note: `run term` will not display runtime errors. In order to see these, please use
77+ /// `run web`
7578 #[ structopt( verbatim_doc_comment) ]
7679 Term {
7780 #[ structopt( parse( from_os_str) ) ]
@@ -86,14 +89,17 @@ enum Run {
8689 raw : bool ,
8790 /// Show only the blue robot's logs
8891 #[ structopt( long) ]
92+ no_logs : bool ,
93+ /// Show only the blue robot's logs
94+ #[ structopt( long) ]
8995 blue_logs_only : bool ,
9096 /// Show only the red robot's logs
9197 #[ structopt( long) ]
9298 red_logs_only : bool ,
9399 /// Only show the results of the battle
94100 #[ structopt( long) ]
95101 results_only : bool ,
96- /// Choose the gamemode. Current supported: "Normal"
102+ /// Choose the gamemode. Current supported: "Normal" (default) | "Hill"
97103 #[ structopt( long, parse( from_os_str) ) ]
98104 game_mode : Option < OsString > ,
99105 /// Specify a random seed for robot spawning. It can be of any length.
@@ -127,6 +133,9 @@ enum Run {
127133 /// The network port to listen to.
128134 #[ structopt( short, long, env = "PORT" ) ]
129135 port : Option < u16 > ,
136+ /// Choose the gamemode. Current supported: "Normal" (default) | "Hill"
137+ #[ structopt( long, parse( from_os_str) ) ]
138+ game_mode : Option < OsString > ,
130139 } ,
131140}
132141
@@ -376,6 +385,7 @@ async fn try_main() -> anyhow::Result<()> {
376385 redbot,
377386 turn_num,
378387 raw,
388+ no_logs,
379389 blue_logs_only,
380390 red_logs_only,
381391 results_only,
@@ -392,6 +402,7 @@ async fn try_main() -> anyhow::Result<()> {
392402 } ,
393403 game_mode,
394404 !raw && !results_only,
405+ no_logs,
395406 red_logs_only,
396407 blue_logs_only,
397408 )
@@ -414,7 +425,7 @@ async fn try_main() -> anyhow::Result<()> {
414425 while let Some ( line) = stdin. next_line ( ) . await . unwrap ( ) {
415426 match serde_json:: from_str ( & line) {
416427 Ok ( game_spec) => {
417- let out = run_game ( game_spec, game_mode, false , false , false ) . await ?;
428+ let out = run_game ( game_spec, game_mode, false , false , false , false ) . await ?;
418429
419430 let mut value = serde_json:: to_value ( & out) . unwrap ( ) ;
420431 if let serde_json:: Value :: Object ( v) = & mut value {
@@ -432,12 +443,14 @@ async fn try_main() -> anyhow::Result<()> {
432443 robots,
433444 address,
434445 port,
446+ game_mode : game_mode_string
435447 } => {
436448 let ids = robots
437449 . iter ( )
438450 . map ( |id| RobotId :: parse ( id) )
439451 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
440- server:: serve ( ids, address, port) . await ?;
452+ let game_mode = parse_game_mode ( game_mode_string) ;
453+ server:: serve ( ids, game_mode, address, port) . await ?;
441454 }
442455 } ,
443456
@@ -802,6 +815,7 @@ async fn run_game(
802815 spec : GameSpec ,
803816 game_mode : GameMode ,
804817 display_turns : bool ,
818+ no_logs : bool ,
805819 red_logs_only : bool ,
806820 blue_logs_only : bool ,
807821) -> anyhow:: Result < MainOutput > {
@@ -827,7 +841,7 @@ async fn run_game(
827841 runners,
828842 |turn_state| {
829843 if display_turns {
830- display:: display_turn ( turn_state, !red_logs_only, !blue_logs_only)
844+ display:: display_turn ( turn_state, !no_logs && ! red_logs_only, !no_logs && !blue_logs_only)
831845 . expect ( "printing failed" ) ;
832846 }
833847 } ,
0 commit comments