From cc97b0ae63724e1268c45af36a6a3cab6f4dcc96 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 18 Nov 2020 20:45:17 +0000 Subject: [PATCH] cli: rename to prep_access_account This reverts commit e212270ec6423f2c11574d70cac0f09ec3873c70. --- src/bin/otter.rs | 66 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/bin/otter.rs b/src/bin/otter.rs index a8c0f6a1..0c7f38d9 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -332,35 +332,7 @@ impl Conn { } #[throws(AE)] - fn list_items(&mut self, pat: &shapelib::ItemSpec) - -> Vec { - let cmd = MgmtCommand::LibraryListByGlob { glob: pat.clone() }; - let mut items = match self.cmd(&cmd)? { - MgmtResponse::LibraryItems(items) => items, - wat => Err(anyhow!("unexpected LibraryListByGlob response: {:?}", - &wat))?, - }; - items.sort(); - items - } -} - -struct ConnForGame { - pub conn: Conn, - pub game: InstanceName, - pub how: MgmtGameUpdateMode, -} -impl Deref for ConnForGame { - type Target = Conn; - fn deref(&self) -> &Conn { &self.conn } -} -impl DerefMut for ConnForGame { - fn deref_mut(&mut self) -> &mut Conn { &mut self.conn } -} - -impl ConnForGame { - #[throws(AE)] - fn prep_access_game(&mut self, ma: &MainOpts) { + fn prep_access_account(&mut self, ma: &MainOpts) { #[derive(Debug)] struct Wantup(bool); impl Wantup { @@ -391,20 +363,48 @@ impl ConnForGame { let mut resp; if wantup.0 { desc = "UpdateAccount"; - resp = self.conn.cmd(&MC::UpdateAccount(clone_via_serde(&ad))); + resp = self.cmd(&MC::UpdateAccount(clone_via_serde(&ad))); } else { desc = "CheckAccount"; - resp = self.conn.cmd(&MC::CheckAccount); + resp = self.cmd(&MC::CheckAccount); }; if is_no_account(&resp) { ad.access.get_or_insert(Box::new(UrlOnStdout)); desc = "CreateAccount"; - resp = self.conn.cmd(&MC::CreateAccount(clone_via_serde(&ad))); + resp = self.cmd(&MC::CreateAccount(clone_via_serde(&ad))); } resp.with_context(||format!("response to {}", &desc))?; } } + #[throws(AE)] + fn list_items(&mut self, pat: &shapelib::ItemSpec) + -> Vec { + let cmd = MgmtCommand::LibraryListByGlob { glob: pat.clone() }; + let mut items = match self.cmd(&cmd)? { + MgmtResponse::LibraryItems(items) => items, + wat => Err(anyhow!("unexpected LibraryListByGlob response: {:?}", + &wat))?, + }; + items.sort(); + items + } +} + +struct ConnForGame { + pub conn: Conn, + pub game: InstanceName, + pub how: MgmtGameUpdateMode, +} +impl Deref for ConnForGame { + type Target = Conn; + fn deref(&self) -> &Conn { &self.conn } +} +impl DerefMut for ConnForGame { + fn deref_mut(&mut self) -> &mut Conn { &mut self.conn } +} + +impl ConnForGame { #[throws(AE)] fn join_game(&mut self, ma: &MainOpts) { let insns = vec![ @@ -623,7 +623,7 @@ fn access_game(ma: &MainOpts, table_name: &String) -> ConnForGame { game: ma.instance_name(table_name), how: MgmtGameUpdateMode::Online, }; - chan.prep_access_game(ma)?; + chan.prep_access_account(ma)?; chan.join_game(&ma)?; chan } -- 2.30.2