From 92096907f3e99c88858a958656ad8b6ace1105a2 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 16 May 2024 02:10:54 +1000 Subject: [PATCH] Make CLI component pub accessible (#369) * Make CLI component pub accessible * fix clippy errors --- src/cli/decode.rs | 5 +++++ src/cli/encode.rs | 5 +++++ src/cli/guess.rs | 5 +++++ src/cli/mod.rs | 8 ++++---- src/cli/types.rs | 9 +++++++-- src/cli/types/list.rs | 5 +++++ 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/cli/decode.rs b/src/cli/decode.rs index d60c989c..8eabf0ff 100644 --- a/src/cli/decode.rs +++ b/src/cli/decode.rs @@ -115,6 +115,11 @@ macro_rules! run_x { } impl Cmd { + /// Run the CLIs decode command. + /// + /// ## Errors + /// + /// If the command is configured with state that is invalid. pub fn run(&self, channel: &Channel) -> Result<(), Error> { match channel { Channel::Curr => self.run_curr()?, diff --git a/src/cli/encode.rs b/src/cli/encode.rs index ba588790..07da4b07 100644 --- a/src/cli/encode.rs +++ b/src/cli/encode.rs @@ -131,6 +131,11 @@ macro_rules! run_x { } impl Cmd { + /// Run the CLIs encode command. + /// + /// ## Errors + /// + /// If the command is configured with state that is invalid. pub fn run(&self, channel: &Channel) -> Result<(), Error> { match channel { Channel::Curr => self.run_curr()?, diff --git a/src/cli/guess.rs b/src/cli/guess.rs index 4f48820b..5212fc04 100644 --- a/src/cli/guess.rs +++ b/src/cli/guess.rs @@ -128,6 +128,11 @@ macro_rules! run_x { } impl Cmd { + /// Run the CLIs guess command. + /// + /// ## Errors + /// + /// If the command is configured with state that is invalid. pub fn run(&self, channel: &Channel) -> Result<(), Error> { match channel { Channel::Curr => self.run_curr()?, diff --git a/src/cli/mod.rs b/src/cli/mod.rs index f8da43ad..1fea239c 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,7 +1,7 @@ -mod decode; -mod encode; -mod guess; -mod types; +pub mod decode; +pub mod encode; +pub mod guess; +pub mod types; mod version; use clap::{Parser, Subcommand, ValueEnum}; diff --git a/src/cli/types.rs b/src/cli/types.rs index a0ad2790..f089930e 100644 --- a/src/cli/types.rs +++ b/src/cli/types.rs @@ -1,4 +1,4 @@ -mod list; +pub mod list; use clap::{Args, Subcommand}; @@ -12,11 +12,16 @@ pub struct Cmd { } #[derive(Subcommand, Clone, Debug)] -pub enum Sub { +enum Sub { List(list::Cmd), } impl Cmd { + /// Run the CLIs types command. + /// + /// ## Panics + /// + /// If the lists sub-command panics. pub fn run(&self, channel: &Channel) { match &self.sub { Sub::List(c) => c.run(channel), diff --git a/src/cli/types/list.rs b/src/cli/types/list.rs index 30054ac4..a5641e0c 100644 --- a/src/cli/types/list.rs +++ b/src/cli/types/list.rs @@ -24,6 +24,11 @@ impl Default for OutputFormat { } impl Cmd { + /// Run the CLIs types list command. + /// + /// ## Panics + /// + /// If the list cannot be rendered as JSON. pub fn run(&self, channel: &Channel) { let types = Self::types(channel); match self.output {