From 373a10660bdd1faf27d22073380e5e897870ab12 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 2 Apr 2026 22:18:09 +0300 Subject: task zy: move GUI application launch out of Processor into cmd/main.go [SoC] Replace Processor.RunGUIMode() with a standalone runGUIMode() function in the composition root (cmd/main.go) that calls proc.GUIConfig() to get the GUI settings and then owns the gui.New()/Run() lifecycle. The processor package still imports gui for the gui.Config return type; complete removal of that import is deferred to task 000 (god-object decomposition) where the Processor itself will be split up. Co-Authored-By: Claude Sonnet 4.6 --- cmd/totalrecall/main.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/totalrecall/main.go b/cmd/totalrecall/main.go index d81bf4a..b1ed51c 100644 --- a/cmd/totalrecall/main.go +++ b/cmd/totalrecall/main.go @@ -9,6 +9,8 @@ import ( "codeberg.org/snonux/totalrecall/internal/archive" "codeberg.org/snonux/totalrecall/internal/cli" + appconfig "codeberg.org/snonux/totalrecall/internal/config" + "codeberg.org/snonux/totalrecall/internal/gui" "codeberg.org/snonux/totalrecall/internal/models" "codeberg.org/snonux/totalrecall/internal/processor" ) @@ -77,7 +79,7 @@ func runCommand(cmd *cobra.Command, args []string, flags *cli.Flags) error { } } else { // No input provided - launch GUI mode by default - return proc.RunGUIMode() + return runGUIMode(proc, flags) } // Generate Anki file if requested @@ -94,3 +96,28 @@ func runCommand(cmd *cobra.Command, args []string, flags *cli.Flags) error { fmt.Printf("\nDone! Materials saved to: %s\n", flags.OutputDir) return nil } + +// runGUIMode launches the GUI application. It lives in cmd/main.go so that +// gui.New() is called from the composition root rather than from the +// processor package, reducing the processor→gui import coupling. +func runGUIMode(proc *processor.Processor, flags *cli.Flags) error { + guiConfig := proc.GUIConfig() + + // Only override OutputDir when the user explicitly set a non-default path. + home, err := appconfig.HomeDir() + if err != nil { + fmt.Fprintf(os.Stderr, "Warning: %v\n", err) + } + defaultOutputDir := filepath.Join(home, "Downloads") + if flags.OutputDir != defaultOutputDir { + guiConfig.OutputDir = flags.OutputDir + } + if guiConfig.GoogleAPIKey == "" { + guiConfig.GoogleAPIKey = cli.GetGoogleAPIKey() + } + + app := gui.New(guiConfig) + app.Run() + + return nil +} -- cgit v1.2.3