chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 22 Aug 2020 22:15:35 +0000 (23:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 22 Aug 2020 22:15:35 +0000 (23:15 +0100)
src/bin/otter.rs

index 8fc2db41f946bcfd35b6d81408cb6067ea528bb9..c2c2dcb2b9e9c11ec6c682981c0d8e21cb694fc4 100644 (file)
@@ -199,7 +199,9 @@ impl Conn {
       Fine | GamesList{..} => { },
       AlterGame { error: None, .. } => { },
       Error { error } => {
-        Err(error.clone()).context(format!("response to: {:?}",&cmd))?;
+        Err(error.clone()).context(
+          format!("got error response to: {:?}",&cmd)
+        )?;
       },
       AlterGame { error: Some(error), .. } => {
         Err(error.clone()).context(format!(
@@ -461,8 +463,19 @@ mod reset_game {
       how: MgmtGameUpdateMode::Bulk,
     };
     let game : GameSpec = read_spec(&args.game_file, "game spec")?;
+
     if let Some(table_file) = args.table_file {
       let table_spec = read_spec(&table_file, "table spec")?;
+      chan.cmd(&MgmtCommand::CreateGame {
+        name: args.name.clone(),
+        insns: vec![],
+      }).map(|_|()).or_else(|e| {
+        if let Some(&MgmtError::AlreadyExists) = e.downcast_ref() {
+          return Ok(())
+        }
+        Err(e)
+      })?;
+
       setup_table(&mut chan, &table_spec)?;
     }