Files
himalaya/src/folder/command/mod.rs
T
Perma Alesheikh 5a0ff83a5e replace anyhow and log with color_eyre and tracing
Since Himalaya is intended to be ran as a CLI in the terminal emulator
environment, their user experience could vastly improve with better and
more colorful error messages and logging.

This change will replace more minimal libraries for error-reporting/han-
dling with their more advanced counterparts.

Since these crates have tight integrations, this commit will change both
in one shot.

Also we have don't need env_logger any more. So I also have removed that
guy as well.

Signed-off-by: Perma Alesheikh <me@prma.dev>
2024-04-15 12:17:56 +02:00

51 lines
1.3 KiB
Rust

mod add;
mod delete;
mod expunge;
mod list;
mod purge;
use color_eyre::Result;
use clap::Subcommand;
use crate::{config::TomlConfig, printer::Printer};
use self::{
add::AddFolderCommand, delete::FolderDeleteCommand, expunge::FolderExpungeCommand,
list::FolderListCommand, purge::FolderPurgeCommand,
};
/// Manage folders.
///
/// A folder (as known as mailbox, or directory) contains one or more
/// emails. This subcommand allows you to manage them.
#[derive(Debug, Subcommand)]
pub enum FolderSubcommand {
#[command(visible_alias = "create", alias = "new")]
Add(AddFolderCommand),
#[command(alias = "lst")]
List(FolderListCommand),
#[command()]
Expunge(FolderExpungeCommand),
#[command()]
Purge(FolderPurgeCommand),
#[command(alias = "remove", alias = "rm")]
Delete(FolderDeleteCommand),
}
impl FolderSubcommand {
#[allow(unused)]
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
match self {
Self::Add(cmd) => cmd.execute(printer, config).await,
Self::List(cmd) => cmd.execute(printer, config).await,
Self::Expunge(cmd) => cmd.execute(printer, config).await,
Self::Purge(cmd) => cmd.execute(printer, config).await,
Self::Delete(cmd) => cmd.execute(printer, config).await,
}
}
}