Files
Devour/cmd/sync.go
T
Tomas Dvorak 55885a0e8f first commit
2026-02-22 10:42:17 +01:00

63 lines
1.5 KiB
Go

package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var syncCmd = &cobra.Command{
Use: "sync",
Short: "Synchronize with configured sources",
Long: `Fetch updates from all configured sources.
Checks each source for changes (using hash or timestamp comparison)
and updates the index accordingly.
Examples:
devour sync # Sync all sources
devour sync --source my-docs # Sync specific source
devour sync --rebuild # Full rebuild`,
RunE: runSync,
}
var (
syncSource string
syncRebuild bool
syncForce bool
)
func init() {
syncCmd.Flags().StringVarP(&syncSource, "source", "s", "", "sync specific source only")
syncCmd.Flags().BoolVar(&syncRebuild, "rebuild", false, "rebuild entire index")
syncCmd.Flags().BoolVarP(&syncForce, "force", "f", false, "force sync even if no changes detected")
}
func runSync(cmd *cobra.Command, args []string) error {
if syncRebuild {
fmt.Println("🔄 Rebuilding index from all sources...")
} else {
fmt.Println("🔄 Syncing with configured sources...")
}
if syncSource != "" {
fmt.Printf(" Source: %s\n", syncSource)
}
// TODO: Implement actual sync logic
// 1. Load sources from config
// 2. For each source:
// a. Check for changes (hash/timestamp)
// b. If changes detected or --force:
// - Scrape updated content
// - Re-generate embeddings
// - Update index
// 3. Update metadata
fmt.Println()
fmt.Println("⚠️ Sync functionality not yet implemented")
fmt.Println(" Configure sources in devour.yaml first")
return nil
}