i dont like commits

This commit is contained in:
Tomas Dvorak
2026-02-24 12:10:13 +01:00
parent 898a3c303f
commit 1d72a1cc01
109 changed files with 43586 additions and 8484 deletions
+7 -4
View File
@@ -4,6 +4,7 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"net/url"
"os"
@@ -87,7 +88,7 @@ func init() {
func runScrape(cmd *cobra.Command, args []string) error {
cfg, err := loadAppConfig()
if err != nil {
return err
return fmt.Errorf("load app config for scrape command: %w", err)
}
if scrapeSources != "" {
@@ -122,7 +123,7 @@ func runScrape(cmd *cobra.Command, args []string) error {
outputDir := resolveOutputDir(cfg, scrapeOutput)
count, err := scrapeOne(cmd, cfg, source, outputDir)
if err != nil {
return err
return fmt.Errorf("scrape source %q: %w", sourceURL, err)
}
if cfg.Indexing.Enabled {
@@ -151,7 +152,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
Sources []appconfig.SourceConfig `yaml:"sources"`
}
if wrapErr := yaml.Unmarshal(raw, &wrapped); wrapErr != nil {
return fmt.Errorf("parse sources file: %w", err)
return fmt.Errorf("parse sources file: %w", wrapErr)
}
list = wrapped.Sources
}
@@ -167,6 +168,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
success := 0
failures := 0
totalDocs := 0
sourceErrors := make([]error, 0)
for _, srcCfg := range list {
source := sourceFromConfig(srcCfg)
if source.Type == "" {
@@ -189,6 +191,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
if srcErr != nil {
failures++
fmt.Printf("✗ %s failed: %v\n", source.Name, srcErr)
sourceErrors = append(sourceErrors, fmt.Errorf("%s: %w", source.Name, srcErr))
continue
}
totalDocs += count
@@ -204,7 +207,7 @@ func scrapeFromConfig(cmd *cobra.Command, cfg *appconfig.Config, configPath stri
fmt.Printf("\nSummary: %d succeeded, %d failed, %d docs written\n", success, failures, totalDocs)
if failures > 0 {
return fmt.Errorf("one or more sources failed")
return fmt.Errorf("one or more sources failed: %w", errors.Join(sourceErrors...))
}
return nil
}