pub(crate) mod add;
pub(crate) mod list;
pub(crate) mod remove;
use anyhow::Result;
use clap::{Parser, Subcommand};
use crate::gmail::client::GmailClient;
#[derive(Parser)]
pub struct LabelCommand {
#[command(subcommand)]
pub command: LabelSubcommands,
}
#[derive(Subcommand)]
pub enum LabelSubcommands {
List(list::ListCommand),
Add(add::AddCommand),
Remove(remove::RemoveCommand),
}
impl LabelCommand {
pub async fn execute(self, client: &GmailClient) -> Result<()> {
match self.command {
LabelSubcommands::List(cmd) => cmd.execute(client).await,
LabelSubcommands::Add(cmd) => cmd.execute(client).await,
LabelSubcommands::Remove(cmd) => cmd.execute(client).await,
}
}
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
#[test]
fn label_subcommands_list_variant() {
let cmd = LabelCommand {
command: LabelSubcommands::List(list::ListCommand {
output: crate::cli::gmail::format::OutputFormat::Table,
}),
};
assert!(matches!(cmd.command, LabelSubcommands::List(_)));
}
}