summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-21 23:22:38 +0300
committerPaul Buetow <paul@buetow.org>2025-07-21 23:22:38 +0300
commitbc1c6e76d5a6ef2623d26d277473c459dd699f81 (patch)
tree3bc0c7b4b730d50fb15ae38458037fe2f8ac4b2f /cmd
parenta43d503533f301db43af412167fda26364542e27 (diff)
feat: Enhanced bulk import, archive functionality, and export improvements
## Bulk Import Enhancements - Added support for three flexible batch file formats: - `BULGARIAN = ENGLISH` - Both provided, no translation needed - `= ENGLISH` - Only English provided, auto-translated to Bulgarian - `BULGARIAN` - Only Bulgarian provided, auto-translated to English - Implemented smart file checking to skip already processed words - Check all required files (word.txt, translation.txt, phonetic.txt, audio/image files and their attribution/metadata) - Added batch processing summary with statistics ## Archive Functionality - Renamed --clear flag to --archive for clarity - Archive cards directory to ~/.local/state/totalrecall/archive/cards-TIMESTAMP - Added archive button to GUI toolbar with folder icon - Archive confirmation dialog supports keyboard shortcuts (y/n/c/ESC) ## Export Improvements - Anki exports now show full file path in output - Changed default export location to home directory (~) for both CLI and GUI - Auto-adjust image size to 1024x1024 when DALL-E 3 is selected ## Other Improvements - Added TranslateEnglishToBulgarian method for reverse translation - Enhanced batch processing with better error handling and progress reporting - Improved file integrity checking for complete word processing 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/totalrecall/main.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/cmd/totalrecall/main.go b/cmd/totalrecall/main.go
index 35364a3..a17bc83 100644
--- a/cmd/totalrecall/main.go
+++ b/cmd/totalrecall/main.go
@@ -3,9 +3,11 @@ package main
import (
"fmt"
"os"
+ "path/filepath"
"github.com/spf13/cobra"
+ "codeberg.org/snonux/totalrecall/internal/archive"
"codeberg.org/snonux/totalrecall/internal/cli"
"codeberg.org/snonux/totalrecall/internal/models"
"codeberg.org/snonux/totalrecall/internal/processor"
@@ -40,12 +42,29 @@ func runCommand(cmd *cobra.Command, args []string, flags *cli.Flags) error {
// Output directory already set by flags
}
+ // Handle --archive flag
+ if flags.Archive {
+ home, _ := os.UserHomeDir()
+ cardsDir := filepath.Join(home, ".local", "state", "totalrecall", "cards")
+ if err := archive.ArchiveCards(cardsDir); err != nil {
+ return fmt.Errorf("failed to archive cards: %w", err)
+ }
+ return nil
+ }
+
// Handle --list-models flag
if flags.ListModels {
lister := models.NewLister(cli.GetOpenAIKey())
return lister.ListAvailableModels()
}
+ // Auto-adjust image size for DALL-E 3
+ if flags.OpenAIImageModel == "dall-e-3" && !cmd.Flags().Changed("openai-image-size") {
+ // If user didn't explicitly set size, use 1024x1024 for DALL-E 3
+ flags.OpenAIImageSize = "1024x1024"
+ fmt.Printf("Note: Using image size 1024x1024 for DALL-E 3 (use --openai-image-size to override)\n")
+ }
+
// Create processor
proc := processor.NewProcessor(flags)
@@ -68,14 +87,11 @@ func runCommand(cmd *cobra.Command, args []string, flags *cli.Flags) error {
// Generate Anki file if requested
if flags.GenerateAnki {
fmt.Printf("\nGenerating Anki import file...\n")
- if err := proc.GenerateAnkiFile(); err != nil {
+ outputPath, err := proc.GenerateAnkiFile()
+ if err != nil {
fmt.Fprintf(os.Stderr, "Warning: Failed to generate Anki file: %v\n", err)
} else {
- if flags.AnkiCSV {
- fmt.Println("Anki import file created: anki_import.csv")
- } else {
- fmt.Printf("Anki package created: %s.apkg\n", flags.DeckName)
- }
+ fmt.Printf("Anki package created: %s\n", outputPath)
}
}