From 5bcfc8fd29475aab5e6e637b336d59111c2070c6 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Tue, 21 Oct 2025 13:48:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20allow=20init=20command=20?= =?UTF-8?q?to=20run=20without=20existing=20config=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move init command handling before config loading in CLI dispatcher - Prevents init from failing when no configuration exists yet - Fixes CircleCI test failures where init was trying to load ~/.cull-gmail/cull-gmail.toml - All integration tests now pass in CI environment --- src/cli/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cli/main.rs b/src/cli/main.rs index 66b07f4..d833fe4 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -290,6 +290,13 @@ async fn main() { /// - Subcommand execution /// - Rule processing operations async fn run(args: Cli) -> Result<()> { + // Handle init command first, before trying to load config + if let Some(SubCmds::Init(init_cli)) = args.sub_command { + // Init commands don't need existing config since they set up the config + return init_cli.run().await; + } + + // For all other commands, load config normally let (config, client_config) = get_config()?; // Check for token restoration before client initialization @@ -304,9 +311,9 @@ async fn run(args: Cli) -> Result<()> { }; match sub_command { - SubCmds::Init(init_cli) => { - // Init commands don't need a Gmail client since they set up the config - init_cli.run().await + SubCmds::Init(_) => { + // This should never be reached due to early return above + unreachable!("Init command should have been handled earlier"); } SubCmds::Message(messages_cli) => messages_cli.run(&mut client).await, SubCmds::Labels(labels_cli) => labels_cli.run(client).await,