mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 05:07:55 +08:00
rename imap folder into mailbox
This commit is contained in:
+5
-110
@@ -1,50 +1,22 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{Args, CommandFactory, Parser, Subcommand};
|
||||
use clap::{Parser, Subcommand};
|
||||
use pimalaya_toolbox::{
|
||||
config::TomlConfig,
|
||||
long_version,
|
||||
terminal::{
|
||||
clap::{
|
||||
args::{AccountArg, JsonFlag, LogFlags},
|
||||
commands::{CompletionCommand, ManualCommand},
|
||||
parsers::path_parser,
|
||||
},
|
||||
printer::Printer,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
// account::command::AccountSubcommand,
|
||||
account::Account,
|
||||
config::Config,
|
||||
folder::command::MailboxCommand, // message::{
|
||||
// attachment::command::AttachmentSubcommand, command::MessageSubcommand,
|
||||
// template::command::TemplateSubcommand,
|
||||
// },
|
||||
};
|
||||
|
||||
/// IMAP CLI (requires `imap` cargo feature).
|
||||
///
|
||||
/// This command gives you access to the IMAP CLI API, and allows
|
||||
/// you to manage IMAP mailboxes: list mailboxes, read messages,
|
||||
/// add flags etc.
|
||||
#[derive(Debug, Subcommand)]
|
||||
#[command(rename_all = "lowercase")]
|
||||
pub enum ImapCommand {
|
||||
#[command(subcommand)]
|
||||
#[command(aliases = ["mboxes", "mbox"])]
|
||||
Mailboxes(MailboxCommand),
|
||||
}
|
||||
|
||||
impl ImapCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: Account) -> Result<()> {
|
||||
match self {
|
||||
Self::Mailboxes(cmd) => cmd.execute(printer, account),
|
||||
}
|
||||
}
|
||||
}
|
||||
use crate::config::Config;
|
||||
#[cfg(feature = "imap")]
|
||||
use crate::imap::command::ImapCommand;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = env!("CARGO_PKG_NAME"))]
|
||||
@@ -78,6 +50,7 @@ pub struct HimalayaCli {
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum BackendCommand {
|
||||
#[cfg(feature = "imap")]
|
||||
#[command(subcommand)]
|
||||
Imap(ImapCommand),
|
||||
}
|
||||
@@ -98,81 +71,3 @@ impl BackendCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum HimalayaCommand {
|
||||
// #[command(subcommand)]
|
||||
// #[command(alias = "accounts")]
|
||||
// Account(AccountSubcommand),
|
||||
#[command(subcommand)]
|
||||
#[command(visible_alias = "mailbox", aliases = ["mailboxes", "mboxes", "mbox"])]
|
||||
#[command(alias = "folders")]
|
||||
Folder(MailboxCommand),
|
||||
|
||||
// #[command(subcommand)]
|
||||
// #[command(alias = "envelopes")]
|
||||
// Envelope(EnvelopeSubcommand),
|
||||
|
||||
// #[command(subcommand)]
|
||||
// #[command(alias = "flags")]
|
||||
// Flag(FlagSubcommand),
|
||||
|
||||
// #[command(subcommand)]
|
||||
// #[command(alias = "messages", alias = "msgs", alias = "msg")]
|
||||
// Message(MessageSubcommand),
|
||||
|
||||
// #[command(subcommand)]
|
||||
// #[command(alias = "attachments")]
|
||||
// Attachment(AttachmentSubcommand),
|
||||
|
||||
// #[command(subcommand)]
|
||||
// #[command(alias = "templates", alias = "tpls", alias = "tpl")]
|
||||
// Template(TemplateSubcommand),
|
||||
#[command(arg_required_else_help = true, alias = "mans")]
|
||||
Manuals(ManualCommand),
|
||||
#[command(arg_required_else_help = true)]
|
||||
Completions(CompletionCommand),
|
||||
}
|
||||
|
||||
impl HimalayaCommand {
|
||||
pub fn execute(
|
||||
self,
|
||||
printer: &mut impl Printer,
|
||||
config_paths: &[PathBuf],
|
||||
account_name: Option<&str>,
|
||||
) -> Result<()> {
|
||||
match self {
|
||||
// Self::Account(cmd) => {
|
||||
// let config = TomlConfig::from_paths_or_default(config_paths).await?;
|
||||
// cmd.execute(printer, config, config_paths.first()).await
|
||||
// }
|
||||
Self::Folder(cmd) => {
|
||||
let config = Config::from_paths_or_default(config_paths)?;
|
||||
let (_, account) = config.get_account(account_name)?;
|
||||
cmd.execute(printer, account)
|
||||
}
|
||||
// Self::Envelope(cmd) => {
|
||||
// let config = TomlConfig::from_paths_or_default(config_paths).await?;
|
||||
// cmd.execute(printer, &config).await
|
||||
// }
|
||||
// Self::Flag(cmd) => {
|
||||
// let config = TomlConfig::from_paths_or_default(config_paths).await?;
|
||||
// cmd.execute(printer, &config).await
|
||||
// }
|
||||
// Self::Message(cmd) => {
|
||||
// let config = TomlConfig::from_paths_or_default(config_paths).await?;
|
||||
// cmd.execute(printer, &config).await
|
||||
// }
|
||||
// Self::Attachment(cmd) => {
|
||||
// let config = TomlConfig::from_paths_or_default(config_paths).await?;
|
||||
// cmd.execute(printer, &config).await
|
||||
// }
|
||||
// Self::Template(cmd) => {
|
||||
// let config = TomlConfig::from_paths_or_default(config_paths).await?;
|
||||
// cmd.execute(printer, &config).await
|
||||
// }
|
||||
Self::Manuals(cmd) => cmd.execute(printer, HimalayaCli::command()),
|
||||
Self::Completions(cmd) => cmd.execute(printer, HimalayaCli::command()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user