✨ feat(cli): implement label subcommand
- adds label subcommand to manage labels associated with rules - provides list, add, and remove subcommands for label management
This commit is contained in:
committed by
Jeremiah Russell
parent
098160ab78
commit
06da00ac68
40
src/config_cli/label_cli.rs
Normal file
40
src/config_cli/label_cli.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use clap::{Parser, Subcommand};
|
||||||
|
use cull_gmail::{Config, Error};
|
||||||
|
|
||||||
|
mod add_cli;
|
||||||
|
mod list_cli;
|
||||||
|
mod remove_cli;
|
||||||
|
|
||||||
|
use add_cli::AddCli;
|
||||||
|
use list_cli::ListCli;
|
||||||
|
use remove_cli::RemoveCli;
|
||||||
|
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
pub enum LabelCommands {
|
||||||
|
/// List the labels associated with a rule
|
||||||
|
#[clap(name = "list")]
|
||||||
|
List(ListCli),
|
||||||
|
/// Add label to rule
|
||||||
|
#[clap(name = "add")]
|
||||||
|
Add(AddCli),
|
||||||
|
/// Remove a label from a
|
||||||
|
#[clap(name = "remove", alias = "rm")]
|
||||||
|
Remove(RemoveCli),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
pub struct LabelCli {
|
||||||
|
/// Configuration commands
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: LabelCommands,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LabelCli {
|
||||||
|
pub fn run(&self, config: Config) -> Result<(), Error> {
|
||||||
|
match &self.command {
|
||||||
|
LabelCommands::List(list_cli) => list_cli.run(config),
|
||||||
|
LabelCommands::Add(add_cli) => add_cli.run(config),
|
||||||
|
LabelCommands::Remove(rm_cli) => rm_cli.run(config),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user