mirror of
https://github.com/soywod/himalaya.git
synced 2024-09-05 18:41:11 +00:00
rename output cli to arg
This commit is contained in:
parent
94e9711c58
commit
e41a71648c
|
@ -16,7 +16,7 @@ use himalaya::{
|
||||||
msg,
|
msg,
|
||||||
smtp::service::SmtpService,
|
smtp::service::SmtpService,
|
||||||
},
|
},
|
||||||
output::{cli::output_args, service::OutputService},
|
output::{self, service::OutputService},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn create_app<'a>() -> clap::App<'a, 'a> {
|
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"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
.about(env!("CARGO_PKG_DESCRIPTION"))
|
.about(env!("CARGO_PKG_DESCRIPTION"))
|
||||||
.author(env!("CARGO_PKG_AUTHORS"))
|
.author(env!("CARGO_PKG_AUTHORS"))
|
||||||
.args(&output_args())
|
.args(&output::arg::args())
|
||||||
.args(&config::arg::args())
|
.args(&config::arg::args())
|
||||||
.arg(mbox::arg::source_arg())
|
.arg(mbox::arg::source_arg())
|
||||||
.subcommands(compl::arg::subcmds())
|
.subcommands(compl::arg::subcmds())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use clap::Arg;
|
use clap::Arg;
|
||||||
|
|
||||||
pub fn output_args<'a>() -> Vec<Arg<'a, 'a>> {
|
/// Output arguments.
|
||||||
|
pub fn args<'a>() -> Vec<Arg<'a, 'a>> {
|
||||||
vec![
|
vec![
|
||||||
Arg::with_name("output")
|
Arg::with_name("output")
|
||||||
.long("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.
|
//! Module related to output formatting and printing.
|
||||||
|
|
||||||
pub mod cli;
|
pub mod arg;
|
||||||
pub mod service;
|
pub mod service;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
Loading…
Reference in a new issue