mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 09:05:13 +00:00
rename output cli to arg
This commit is contained in:
parent
94e9711c58
commit
e41a71648c
|
@ -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())
|
||||
|
|
|
@ -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")
|
|
@ -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
|
|
@ -1,5 +1,5 @@
|
|||
//! Module related to output formatting and printing.
|
||||
|
||||
pub mod cli;
|
||||
pub mod arg;
|
||||
pub mod service;
|
||||
pub mod utils;
|
||||
|
|
Loading…
Reference in a new issue