mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 05:07:55 +08:00
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
mod add;
|
|
mod remove;
|
|
mod set;
|
|
|
|
use anyhow::Result;
|
|
use clap::Subcommand;
|
|
|
|
use crate::{config::TomlConfig, printer::Printer};
|
|
|
|
use self::{add::FlagAddCommand, remove::FlagRemoveCommand, set::FlagSetCommand};
|
|
|
|
/// Subcommand to manage flags
|
|
#[derive(Debug, Subcommand)]
|
|
pub enum FlagSubcommand {
|
|
/// Add flag(s) to an envelope
|
|
#[command(arg_required_else_help = true)]
|
|
#[command(alias = "create")]
|
|
Add(FlagAddCommand),
|
|
|
|
/// Replace flag(s) of an envelope
|
|
#[command(arg_required_else_help = true)]
|
|
#[command(aliases = ["update", "change", "replace"])]
|
|
Set(FlagSetCommand),
|
|
|
|
/// Remove flag(s) from an envelope
|
|
#[command(arg_required_else_help = true)]
|
|
#[command(aliases = ["rm", "delete", "del"])]
|
|
Remove(FlagRemoveCommand),
|
|
}
|
|
|
|
impl FlagSubcommand {
|
|
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
|
|
match self {
|
|
Self::Add(cmd) => cmd.execute(printer, config).await,
|
|
Self::Set(cmd) => cmd.execute(printer, config).await,
|
|
Self::Remove(cmd) => cmd.execute(printer, config).await,
|
|
}
|
|
}
|
|
}
|