summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/totalrecall/main.go29
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
+}