From 782cfc4bafffce3d083ccdb2451fc2c0b7c7c0c9 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Tue, 7 Oct 2025 08:01:22 +0100 Subject: [PATCH] Merge branch 'implement-config-subcommand' of github.com:jerus-org/cull-gmail --- PRLOG.md | 2 -- src/config_cli.rs | 35 +++++++++++++++++++++++++++++++++++ src/main.rs | 8 +++++++- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/config_cli.rs diff --git a/PRLOG.md b/PRLOG.md index 6d5bd3f..c3f13bc 100644 --- a/PRLOG.md +++ b/PRLOG.md @@ -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 [#29]: https://github.com/jerus-org/cull-gmail/pull/29 [#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.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 diff --git a/src/config_cli.rs b/src/config_cli.rs new file mode 100644 index 0000000..e39a4e2 --- /dev/null +++ b/src/config_cli.rs @@ -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, +} diff --git a/src/main.rs b/src/main.rs index 81c6bec..60158e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,11 @@ use clap::{Parser, Subcommand}; +mod config_cli; mod label_cli; mod message_cli; mod trash_cli; +use config_cli::ConfigCli; use cull_gmail::Error; use label_cli::LabelCli; use message_cli::MessageCli; @@ -28,9 +30,12 @@ enum Commands { /// List labels #[clap(name = "label")] Labels(LabelCli), - /// List trash + /// Move messages to trash #[clap(name = "trash")] Trash(TrashCli), + /// Configure end-of-life rules + #[clap(name = "config")] + Config(ConfigCli), } #[tokio::main] @@ -62,6 +67,7 @@ async fn run(args: Cli) -> Result<(), Error> { Commands::Message(list_cli) => list_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::Config(config_cli) => config_cli.run(), } } Ok(())