From: Ian Jackson Date: Wed, 19 May 2021 22:03:49 +0000 (+0100) Subject: otter(1): Move response iteration back into alter_game_adhoc X-Git-Tag: otter-0.6.0~140 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d8c185336923e4d516bf949e615c5fc933372d42;p=otter.git otter(1): Move response iteration back into alter_game_adhoc It turns out that commands want to print responses one at a time. Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 707eb9ac..59bf2a69 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -1398,17 +1398,15 @@ impl AdhocFormat { } #[throws(AE)] - pub fn report(&self, resps: Vec) + pub fn report(&self, resp: T) where T: Serialize { - for resp in resps { - println!("{}", match self.0 { - "json" => serde_json::to_string(&resp).map_err(AE::from), - "ron" => ron::ser:: to_string(&resp).map_err(AE::from), - _ => panic!(), - } - .context("re-format response")?); + println!("{}", match self.0 { + "json" => serde_json::to_string(&resp).map_err(AE::from), + "ron" => ron::ser:: to_string(&resp).map_err(AE::from), + _ => panic!(), } + .context("re-format response")?); } } @@ -1449,7 +1447,9 @@ mod alter_game_adhoc { let insns: Vec = ahf.parse(args.insns, "insn")?; let resps = chan.alter_game(insns,None)?; - ahf.report(resps)?; + for resp in resps { + ahf.report(resp)?; + } Ok(()) }