mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
fix args typos
This commit is contained in:
parent
329af51534
commit
abb9f4172b
|
@ -23,7 +23,7 @@ const ARG_RAW: &str = "raw";
|
|||
const ARG_REPLY_ALL: &str = "reply-all";
|
||||
const CMD_ATTACHMENTS: &str = "attachments";
|
||||
const CMD_COPY: &str = "copy";
|
||||
const CMD_DELETE: &str = "delete";
|
||||
const CMD_DEL: &str = "delete";
|
||||
const CMD_FORWARD: &str = "forward";
|
||||
const CMD_LIST: &str = "list";
|
||||
const CMD_MOVE: &str = "move";
|
||||
|
@ -56,7 +56,7 @@ pub(crate) type Ids<'a> = &'a str;
|
|||
pub enum Cmd<'a> {
|
||||
Attachments(Id<'a>),
|
||||
Copy(Id<'a>, Folder<'a>),
|
||||
Delete(Id<'a>),
|
||||
Delete(Ids<'a>),
|
||||
Forward(Id<'a>, Attachments<'a>, Encrypt),
|
||||
List(table::args::MaxTableWidth, Option<PageSize>, Page),
|
||||
Move(Id<'a>, Folder<'a>),
|
||||
|
@ -91,10 +91,10 @@ pub fn matches<'a>(m: &'a ArgMatches) -> Result<Option<Cmd<'a>>> {
|
|||
let id = parse_id_arg(m);
|
||||
let folder = folder::args::parse_target_arg(m);
|
||||
Cmd::Copy(id, folder)
|
||||
} else if let Some(m) = m.subcommand_matches(CMD_DELETE) {
|
||||
} else if let Some(m) = m.subcommand_matches(CMD_DEL) {
|
||||
debug!("delete command matched");
|
||||
let id = parse_id_arg(m);
|
||||
Cmd::Delete(id)
|
||||
let ids = parse_ids_arg(m);
|
||||
Cmd::Delete(ids)
|
||||
} else if let Some(m) = m.subcommand_matches(CMD_FORWARD) {
|
||||
debug!("forward command matched");
|
||||
let id = parse_id_arg(m);
|
||||
|
@ -185,13 +185,13 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
|||
.arg(table::args::max_width()),
|
||||
SubCommand::with_name(CMD_SEARCH)
|
||||
.aliases(&["s", "query", "q"])
|
||||
.about("Lists emails matching the given IMAP query")
|
||||
.about("Lists emails matching the given query")
|
||||
.arg(page_size_arg())
|
||||
.arg(page_arg())
|
||||
.arg(table::args::max_width())
|
||||
.arg(query_arg()),
|
||||
SubCommand::with_name(CMD_SORT)
|
||||
.about("Sorts emails by the given criteria and matching the given IMAP query")
|
||||
.about("Sorts emails by the given criteria and matching the given query")
|
||||
.arg(page_size_arg())
|
||||
.arg(page_arg())
|
||||
.arg(table::args::max_width())
|
||||
|
@ -199,6 +199,7 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
|||
.arg(query_arg()),
|
||||
SubCommand::with_name(CMD_WRITE)
|
||||
.about("Writes a new email")
|
||||
.aliases(&["w", "new", "n"])
|
||||
.args(&tpl::args::args())
|
||||
.arg(attachments_arg())
|
||||
.arg(encrypt_flag()),
|
||||
|
@ -237,10 +238,10 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
|||
.about("Moves an email to the targeted folder")
|
||||
.arg(id_arg())
|
||||
.arg(folder::args::target_arg()),
|
||||
SubCommand::with_name(CMD_DELETE)
|
||||
SubCommand::with_name(CMD_DEL)
|
||||
.aliases(&["del", "d", "remove", "rm"])
|
||||
.about("Deletes an email")
|
||||
.arg(id_arg()),
|
||||
.arg(ids_arg()),
|
||||
],
|
||||
]
|
||||
.concat()
|
||||
|
@ -249,7 +250,7 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
|||
/// Represents the email id argument.
|
||||
pub fn id_arg<'a>() -> Arg<'a, 'a> {
|
||||
Arg::with_name(ARG_ID)
|
||||
.help("Specifies the targeted email")
|
||||
.help("Specifies the target email")
|
||||
.value_name("ID")
|
||||
.required(true)
|
||||
}
|
||||
|
@ -304,11 +305,11 @@ pub fn parse_criteria_arg<'a>(matches: &'a ArgMatches<'a>) -> String {
|
|||
}
|
||||
|
||||
/// Represents the email ids argument.
|
||||
pub fn id_range_arg<'a>() -> Arg<'a, 'a> {
|
||||
pub fn ids_arg<'a>() -> Arg<'a, 'a> {
|
||||
Arg::with_name(ARG_IDS)
|
||||
.help("Specifies targeted email(s)")
|
||||
.long_help("Specifies a range of targeted emails. The range follows the RFC3501 format.")
|
||||
.value_name("RANGE")
|
||||
.help("Specifies the target email(s)")
|
||||
.long_help("Specifies a range of emails. The range follows the RFC3501 format.")
|
||||
.value_name("IDS")
|
||||
.required(true)
|
||||
}
|
||||
|
||||
|
@ -351,14 +352,14 @@ fn page_arg<'a>() -> Arg<'a, 'a> {
|
|||
.short("p")
|
||||
.long("page")
|
||||
.value_name("INT")
|
||||
.default_value("0")
|
||||
.default_value("1")
|
||||
}
|
||||
|
||||
/// Represents the page argument parser.
|
||||
fn parse_page_arg<'a>(matches: &'a ArgMatches<'a>) -> usize {
|
||||
matches
|
||||
.value_of(ARG_PAGE)
|
||||
.unwrap_or("1")
|
||||
.unwrap()
|
||||
.parse()
|
||||
.ok()
|
||||
.map(|page| 1.max(page) - 1)
|
||||
|
@ -453,8 +454,7 @@ pub fn parse_mime_type_arg<'a>(matches: &'a ArgMatches<'a>) -> &'a str {
|
|||
/// Represents the email query argument.
|
||||
pub fn query_arg<'a>() -> Arg<'a, 'a> {
|
||||
Arg::with_name(ARG_QUERY)
|
||||
.help("IMAP query")
|
||||
.long_help("The IMAP query format follows the RFC3501. The query is case-insensitive.")
|
||||
.long_help("The query system depends on the backend, see the wiki for more details")
|
||||
.value_name("QUERY")
|
||||
.multiple(true)
|
||||
.required(true)
|
||||
|
|
|
@ -61,21 +61,21 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
|||
SubCommand::with_name(CMD_ADD)
|
||||
.aliases(&["a"])
|
||||
.about("Adds email flags")
|
||||
.arg(email::args::id_range_arg())
|
||||
.arg(email::args::ids_arg())
|
||||
.arg(flags_arg()),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name(CMD_SET)
|
||||
.aliases(&["s", "change", "c"])
|
||||
.about("Sets email flags")
|
||||
.arg(email::args::id_range_arg())
|
||||
.arg(email::args::ids_arg())
|
||||
.arg(flags_arg()),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name(CMD_DEL)
|
||||
.aliases(&["rem", "rm", "r", "delete", "del", "d"])
|
||||
.about("Removes email flags")
|
||||
.arg(email::args::id_range_arg())
|
||||
.arg(email::args::ids_arg())
|
||||
.arg(flags_arg()),
|
||||
)]
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn source_arg<'a>() -> Arg<'a, 'a> {
|
|||
Arg::with_name(ARG_SOURCE)
|
||||
.short("f")
|
||||
.long("folder")
|
||||
.help("Specifies the folder source")
|
||||
.help("Specifies the source folder")
|
||||
.value_name("SOURCE")
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ pub fn parse_source_arg<'a>(matches: &'a ArgMatches<'a>) -> &'a str {
|
|||
/// Represents the target folder argument.
|
||||
pub fn target_arg<'a>() -> Arg<'a, 'a> {
|
||||
Arg::with_name(ARG_TARGET)
|
||||
.help("Specifies the folder target")
|
||||
.help("Specifies the target folder")
|
||||
.value_name("TARGET")
|
||||
.required(true)
|
||||
}
|
||||
|
|
|
@ -39,15 +39,3 @@ impl fmt::Display for OutputFmt {
|
|||
write!(f, "{}", fmt)
|
||||
}
|
||||
}
|
||||
|
||||
/// Defines a struct-wrapper to provide a JSON output.
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
pub struct OutputJson<T: serde::Serialize> {
|
||||
response: T,
|
||||
}
|
||||
|
||||
impl<T: serde::Serialize> OutputJson<T> {
|
||||
pub fn new(response: T) -> Self {
|
||||
Self { response }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::fmt::{self, Debug};
|
|||
use termcolor::{ColorChoice, StandardStream};
|
||||
|
||||
use crate::{
|
||||
output::{OutputFmt, OutputJson},
|
||||
output::OutputFmt,
|
||||
printer::{Print, PrintTable, PrintTableOpts, WriteColor},
|
||||
};
|
||||
|
||||
|
@ -61,8 +61,8 @@ impl Printer for StdoutPrinter {
|
|||
fn print_struct<T: Debug + Print + serde::Serialize>(&mut self, data: T) -> Result<()> {
|
||||
match self.fmt {
|
||||
OutputFmt::Plain => data.print(self.writer.as_mut()),
|
||||
OutputFmt::Json => serde_json::to_writer(self.writer.as_mut(), &OutputJson::new(data))
|
||||
.context("cannot write JSON to writer"),
|
||||
OutputFmt::Json => serde_json::to_writer(self.writer.as_mut(), &data)
|
||||
.context("cannot write json to writer"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue