diff --git a/src/main.rs b/src/main.rs index 65e4315..a735786 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use himalaya::{ msg, smtp::service::SmtpService, }, - output::{cli::output_args, service::OutputService}, + output::{self, service::OutputService}, }; fn create_app<'a>() -> clap::App<'a, 'a> { @@ -24,7 +24,7 @@ fn create_app<'a>() -> clap::App<'a, 'a> { .version(env!("CARGO_PKG_VERSION")) .about(env!("CARGO_PKG_DESCRIPTION")) .author(env!("CARGO_PKG_AUTHORS")) - .args(&output_args()) + .args(&output::arg::args()) .args(&config::arg::args()) .arg(mbox::arg::source_arg()) .subcommands(compl::arg::subcmds()) diff --git a/src/output/cli.rs b/src/output/arg.rs similarity index 90% rename from src/output/cli.rs rename to src/output/arg.rs index 1ca50c3..b4c49ad 100644 --- a/src/output/cli.rs +++ b/src/output/arg.rs @@ -1,6 +1,7 @@ use clap::Arg; -pub fn output_args<'a>() -> Vec> { +/// Output arguments. +pub fn args<'a>() -> Vec> { vec![ Arg::with_name("output") .long("output") diff --git a/src/output/fmt.rs b/src/output/fmt.rs deleted file mode 100644 index fb8a9ed..0000000 --- a/src/output/fmt.rs +++ /dev/null @@ -1,46 +0,0 @@ -use serde::Serialize; -use std::fmt; - -// Output format - -pub enum OutputFmt { - Plain, - Json, -} - -impl From<&str> for OutputFmt { - fn from(s: &str) -> Self { - match s { - "json" => Self::Json, - "plain" | _ => Self::Plain, - } - } -} - -impl fmt::Display for OutputFmt { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "{}", - match *self { - OutputFmt::Json => "JSON", - OutputFmt::Plain => "PLAIN", - }, - ) - } -} - -// Response helper - -#[derive(Serialize)] -pub struct Response { - response: T, -} - -impl Response { - pub fn new(response: T) -> Self { - Self { response } - } -} - -// Print helper diff --git a/src/output/mod.rs b/src/output/mod.rs index 70f7c0c..ba9f953 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -1,5 +1,5 @@ //! Module related to output formatting and printing. -pub mod cli; +pub mod arg; pub mod service; pub mod utils;