Merge branch 'implement-config-subcommand' of github.com:jerus-org/cull-gmail

This commit is contained in:
Jeremiah Russell
2025-10-07 08:01:22 +01:00
committed by Jeremiah Russell
parent c68d34867e
commit 782cfc4baf
3 changed files with 42 additions and 3 deletions

View File

@@ -99,8 +99,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#28]: https://github.com/jerus-org/cull-gmail/pull/28 [#28]: https://github.com/jerus-org/cull-gmail/pull/28
[#29]: https://github.com/jerus-org/cull-gmail/pull/29 [#29]: https://github.com/jerus-org/cull-gmail/pull/29
[#30]: https://github.com/jerus-org/cull-gmail/pull/30 [#30]: https://github.com/jerus-org/cull-gmail/pull/30
[#33]: https://github.com/jerus-org/cull-gmail/pull/33
[Unreleased]: https://github.com/jerus-org/cull-gmail/compare/v0.0.4...HEAD
[0.0.4]: https://github.com/jerus-org/cull-gmail/compare/v0.0.3...v0.0.4 [0.0.4]: https://github.com/jerus-org/cull-gmail/compare/v0.0.3...v0.0.4
[0.0.3]: https://github.com/jerus-org/cull-gmail/compare/v0.0.2...v0.0.3 [0.0.3]: https://github.com/jerus-org/cull-gmail/compare/v0.0.2...v0.0.3
[0.0.2]: https://github.com/jerus-org/cull-gmail/compare/v0.0.1...v0.0.2 [0.0.2]: https://github.com/jerus-org/cull-gmail/compare/v0.0.1...v0.0.2

35
src/config_cli.rs Normal file
View File

@@ -0,0 +1,35 @@
use clap::{Parser, Subcommand};
#[derive(Debug, Parser)]
pub struct ConfigCli {
/// Configuration commands
#[command(subcommand)]
command: ConfigCommands,
}
impl ConfigCli {
pub fn run(&self) {
match self.command {
ConfigCommands::List => todo!(),
ConfigCommands::Add => todo!(),
ConfigCommands::Remove => todo!(),
ConfigCommands::Update => todo!(),
}
}
}
#[derive(Debug, Subcommand)]
pub enum ConfigCommands {
/// List the rules configured and saved in the config file
#[clap(name = "list")]
List,
/// Add a rules to the config file
#[clap(name = "add")]
Add,
/// Remove a rule from the config file
#[clap(name = "remove", alias = "rm")]
Remove,
/// Update a rule in the config file
#[clap(name = "update")]
Update,
}

View File

@@ -1,9 +1,11 @@
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
mod config_cli;
mod label_cli; mod label_cli;
mod message_cli; mod message_cli;
mod trash_cli; mod trash_cli;
use config_cli::ConfigCli;
use cull_gmail::Error; use cull_gmail::Error;
use label_cli::LabelCli; use label_cli::LabelCli;
use message_cli::MessageCli; use message_cli::MessageCli;
@@ -28,9 +30,12 @@ enum Commands {
/// List labels /// List labels
#[clap(name = "label")] #[clap(name = "label")]
Labels(LabelCli), Labels(LabelCli),
/// List trash /// Move messages to trash
#[clap(name = "trash")] #[clap(name = "trash")]
Trash(TrashCli), Trash(TrashCli),
/// Configure end-of-life rules
#[clap(name = "config")]
Config(ConfigCli),
} }
#[tokio::main] #[tokio::main]
@@ -62,6 +67,7 @@ async fn run(args: Cli) -> Result<(), Error> {
Commands::Message(list_cli) => list_cli.run("credential.json").await?, Commands::Message(list_cli) => list_cli.run("credential.json").await?,
Commands::Labels(label_cli) => label_cli.run("credential.json").await?, Commands::Labels(label_cli) => label_cli.run("credential.json").await?,
Commands::Trash(trash_cli) => trash_cli.run("credential.json").await?, Commands::Trash(trash_cli) => trash_cli.run("credential.json").await?,
Commands::Config(config_cli) => config_cli.run(),
} }
} }
Ok(()) Ok(())