From c9ba372b1b40a047c0b249972e18334845763b78 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:36:29 +1000 Subject: [PATCH 1/2] Add fn for running the root cli command --- src/cli/mod.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index c51bb95d..e2cd8f24 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -26,6 +26,19 @@ pub struct Root { cmd: Cmd, } +impl Root { + pub fn run(&self) -> Result<(), Error> { + match &self.cmd { + Cmd::Types(c) => c.run(&self.channel), + Cmd::Guess(c) => c.run(&self.channel)?, + Cmd::Decode(c) => c.run(&self.channel)?, + Cmd::Encode(c) => c.run(&self.channel)?, + Cmd::Version => version::Cmd::run(), + } + Ok(()) + } +} + #[derive(ValueEnum, Debug, Clone)] pub enum Channel { #[value(name = "+curr")] @@ -78,12 +91,5 @@ where T: Into + Clone, { let root = Root::try_parse_from(args)?; - match root.cmd { - Cmd::Types(c) => c.run(&root.channel), - Cmd::Guess(c) => c.run(&root.channel)?, - Cmd::Decode(c) => c.run(&root.channel)?, - Cmd::Encode(c) => c.run(&root.channel)?, - Cmd::Version => version::Cmd::run(), - } - Ok(()) + root.run() } From 84be9383bc34550840d47770e81e6b7265618beb Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:56:10 +1000 Subject: [PATCH 2/2] fix --- src/cli/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index e2cd8f24..f8da43ad 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -27,6 +27,11 @@ pub struct Root { } impl Root { + /// Run the CLIs root command. + /// + /// ## Errors + /// + /// If the root command is configured with state that is invalid. pub fn run(&self) -> Result<(), Error> { match &self.cmd { Cmd::Types(c) => c.run(&self.channel),