aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-05-12 17:42:56 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-05-12 17:42:56 +0200
commitc74aaaf3c4397bdd2430c5793fc2b70f70ea596c (patch)
tree611568c53d20e1fdc4100d0635ac6321bf616963
parent355bc2aa3b66c8d3afa29fbbf13f31e184dd5724 (diff)
kdev: skip files larger than --maxFileSize (default 1MB)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--cmd/kdev/main.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/cmd/kdev/main.go b/cmd/kdev/main.go
index dc404e0..0dda567 100644
--- a/cmd/kdev/main.go
+++ b/cmd/kdev/main.go
@@ -30,16 +30,17 @@ type Record struct {
}
var (
- excludes map[string]bool = map[string]bool{}
- repoPath string
- after time.Time
- before time.Time
- sortBy string
- maxRecords int
- algo string
- cpuProfile string
- keywords []string
- logLevel string
+ excludes map[string]bool = map[string]bool{}
+ repoPath string
+ after time.Time
+ before time.Time
+ sortBy string
+ maxRecords int
+ maxFileSize int64
+ algo string
+ cpuProfile string
+ keywords []string
+ logLevel string
)
func initConfig() {
@@ -56,6 +57,7 @@ func initConfig() {
pflag.String("cpuProfile", "", "write cpu profile to file")
pflag.StringSlice("excludes", []string{".git", ".kdev.yaml"}, "Excluded directories")
pflag.String("logLevel", "info", "Log level (debug, info, warn, error)")
+ pflag.Int64("maxFileSize", 1024*1024, "Skip files larger than this size in bytes")
pflag.Parse()
viper.SetConfigType("yaml")
@@ -92,6 +94,7 @@ func initConfig() {
for _, exclude := range viper.GetStringSlice("excludes") {
excludes[exclude] = true
}
+ maxFileSize = viper.GetInt64("maxFileSize")
logLevel = viper.GetString("logLevel")
level := slog.LevelInfo
kcore.Expect(level.UnmarshalText([]byte(logLevel)), "Invalid log level")
@@ -176,6 +179,10 @@ func walkRepo(keywords []string, factory RecordExtractorFactory, records *[]Reco
if d.IsDir() {
return nil
}
+ if info, err := d.Info(); err == nil && info.Size() > maxFileSize {
+ slog.Debug("Skipping large file", "path", relativePath, "size", info.Size())
+ return nil
+ }
if isBinaryFile(path) {
return nil
}