From d8c185336923e4d516bf949e615c5fc933372d42 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 19 May 2021 23:03:49 +0100 Subject: [PATCH] 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 --- src/bin/otter.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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(()) } -- 2.30.2