diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-02 22:18:09 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-02 22:18:09 +0300 |
| commit | 373a10660bdd1faf27d22073380e5e897870ab12 (patch) | |
| tree | 3d1e8a8b375aa509c0b4b2b540058cc3a4b3e200 /cmd | |
| parent | bd23c3f3e53bced44b5ecf0b0c6a74a3cc2f9875 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/totalrecall/main.go | 29 |
1 files changed, 28 insertions, 1 deletions
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 +} |
