pub(crate) mod import_legacy;
pub(crate) mod list;
pub(crate) mod set_default;
use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser)]
pub struct AccountCommand {
#[command(subcommand)]
pub command: AccountSubcommands,
}
#[derive(Subcommand)]
pub enum AccountSubcommands {
List(list::ListCommand),
SetDefault(set_default::SetDefaultCommand),
ImportLegacy(import_legacy::ImportLegacyCommand),
}
impl AccountCommand {
pub fn execute(self) -> Result<()> {
match self.command {
AccountSubcommands::List(cmd) => cmd.execute(),
AccountSubcommands::SetDefault(cmd) => cmd.execute(),
AccountSubcommands::ImportLegacy(cmd) => cmd.execute(),
}
}
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
#[test]
fn account_subcommands_list_variant() {
let cmd = AccountCommand {
command: AccountSubcommands::List(list::ListCommand {
output: crate::cli::gmail::format::OutputFormat::Table,
}),
};
assert!(matches!(cmd.command, AccountSubcommands::List(_)));
}
}