From: Ian Jackson Date: Wed, 2 Jun 2021 23:09:27 +0000 (+0100) Subject: Move clear-game out of otter.rs X-Git-Tag: otter-0.7.0~80 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fabbc7a4b9e0529acd1b4e37f62cc0742a9cad72;p=otter.git Move clear-game out of otter.rs Signed-off-by: Ian Jackson --- diff --git a/cli/forgame.rs b/cli/forgame.rs index 21dc8eb5..e5116eed 100644 --- a/cli/forgame.rs +++ b/cli/forgame.rs @@ -377,6 +377,34 @@ mod leave_game { } } +//---------- clear game ---------- + +#[throws(AE)] +fn clear_game(ma: &MainOpts, chan: &mut MgmtChannelForGame) { + chan.alter_game(vec![MGI::ClearGame{ }], None) + .context("clear table")?; + chan.cmd(&MC::ClearBundles { game: ma.instance() }) + .context("clear bundles")?; +} + +mod clear_game { + use super::*; + + type Args = NoArgs; + + #[throws(AE)] + fn call(SCCA{ ma, args,.. }:SCCA) { + let _args = parse_args::(args, &noargs, &ok_id, None); + let mut chan = ma.access_game()?; + clear_game(&ma, &mut chan)?; + } + + inventory_subcmd!{ + "clear-game", + "clear the table and clear out all bundles", + } +} + //---------- delete-game ---------- mod delete_game { diff --git a/cli/otter.rs b/cli/otter.rs index 07189fd3..41726572 100644 --- a/cli/otter.rs +++ b/cli/otter.rs @@ -323,34 +323,6 @@ fn main() { .unwrap_or_else(|e| e.end_process(12)); } -//---------- clear game ---------- - -#[throws(AE)] -fn clear_game(ma: &MainOpts, chan: &mut MgmtChannelForGame) { - chan.alter_game(vec![MGI::ClearGame{ }], None) - .context("clear table")?; - chan.cmd(&MC::ClearBundles { game: ma.instance() }) - .context("clear bundles")?; -} - -mod clear_game { - use super::*; - - type Args = NoArgs; - - #[throws(AE)] - fn call(SCCA{ ma, args,.. }:SCCA) { - let _args = parse_args::(args, &noargs, &ok_id, None); - let mut chan = ma.access_game()?; - clear_game(&ma, &mut chan)?; - } - - inventory_subcmd!{ - "clear-game", - "clear the table and clear out all bundles", - } -} - //---------- list-accounts ---------- mod list_accounts {