rename output cli to arg

This commit is contained in:
Clément DOUIN 2021-09-18 00:32:46 +02:00
parent 94e9711c58
commit e41a71648c
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
4 changed files with 5 additions and 50 deletions

View file

@ -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())

View file

@ -1,6 +1,7 @@
use clap::Arg;
pub fn output_args<'a>() -> Vec<Arg<'a, 'a>> {
/// Output arguments.
pub fn args<'a>() -> Vec<Arg<'a, 'a>> {
vec![
Arg::with_name("output")
.long("output")

View file

@ -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<T: Serialize + fmt::Display> {
response: T,
}
impl<T: Serialize + fmt::Display> Response<T> {
pub fn new(response: T) -> Self {
Self { response }
}
}
// Print helper

View file

@ -1,5 +1,5 @@
//! Module related to output formatting and printing.
pub mod cli;
pub mod arg;
pub mod service;
pub mod utils;