From 9951a5947fa11e3790d65e5aae37f71d6b4a24de Mon Sep 17 00:00:00 2001 From: Bartal Laearsson Date: Fri, 7 Aug 2026 23:26:43 +0100 Subject: [PATCH] ability to omit front end files like .css .js .html and so on --- cmd/root.go | 10 +++++++++- internal/config/config.go | 23 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index addb0b8..0303b00 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -58,6 +58,7 @@ Examples: protonDrive bool drivePath string verticalSlices bool + skipFrontend bool ) func Execute() { @@ -78,6 +79,7 @@ func init() { rootCmd.Flags().BoolVar(&protonDrive, "proton-drive", false, "upload output to Proton Drive after writing locally") rootCmd.Flags().StringVar(&drivePath, "drive-path", "", "full remote path on Proton Drive (e.g. /my-files/md/report.md). Requires --proton-drive") rootCmd.Flags().BoolVar(&verticalSlices, "vertical-slices", false, "split output into root file + one markdown per top-level directory") + rootCmd.Flags().BoolVar(&skipFrontend, "skip-frontend", false, "omit frontend file types (.html, .css, .js, .ts, .vue, .svelte, etc.)") rootCmd.MarkPersistentFlagRequired("output") } @@ -95,6 +97,11 @@ func run(cmd *cobra.Command, args []string) error { return fmt.Errorf("--vertical-slices cannot be used with --input-file") } + excludedExts := append(config.DefaultExts, extensions...) + if skipFrontend { + excludedExts = append(excludedExts, config.FrontendExts...) + } + cfg := &config.Config{ OutputPath: outputPath, AppendMode: appendMode, @@ -102,10 +109,11 @@ func run(cmd *cobra.Command, args []string) error { MaxSize: maxSize, MaxDepth: maxDepth, Ignores: append(config.DefaultIgnores, ignorePatterns...), - Extensions: append(config.DefaultExts, extensions...), + Extensions: excludedExts, ProtonDrive: protonDrive, DrivePath: drivePath, VerticalSlices: verticalSlices, + SkipFrontend: skipFrontend, } if singleFile != "" { diff --git a/internal/config/config.go b/internal/config/config.go index f9993ef..fae07ad 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -35,12 +35,20 @@ var DefaultExts = []string{ ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".pem", ".key", ".cert", ".db", ".sqlite", ".sqlite3", - ".class", // Java compiled bytecode - ".jar", // JAR archives + ".class", + ".jar", ".war", ".ear", } +var FrontendExts = []string{ + ".html", ".htm", ".gohtml", ".tmpl", + ".css", ".scss", ".sass", ".less", + ".js", ".jsx", ".mjs", ".cjs", + ".ts", ".tsx", + ".vue", ".svelte", +} + type stringSlice []string func (s *stringSlice) String() string { @@ -66,6 +74,7 @@ type Config struct { ProtonDrive bool DrivePath string VerticalSlices bool + SkipFrontend bool } func PrintUsage() { @@ -90,6 +99,7 @@ func Parse() (*Config, error) { protonDrive bool drivePath string verticalSlices bool + skipFrontend bool ) flag.StringVar(&input, "i", "", "single file input (append mode only)") @@ -104,6 +114,7 @@ func Parse() (*Config, error) { flag.BoolVar(&protonDrive, "proton-drive", false, "upload output to Proton Drive after writing locally") flag.StringVar(&drivePath, "drive-path", "", "full remote path on Proton Drive (requires --proton-drive)") flag.BoolVar(&verticalSlices, "vertical-slices", false, "split output into root file + one markdown per top-level directory") + flag.BoolVar(&skipFrontend, "skip-frontend", false, "omit frontend file types (.html, .css, .js, .ts, .vue, .svelte, etc.)") flag.Usage = PrintUsage flag.Parse() @@ -129,6 +140,11 @@ func Parse() (*Config, error) { return nil, fmt.Errorf("--vertical-slices cannot be used with --input-file") } + excludedExts := append(DefaultExts, exts...) + if skipFrontend { + excludedExts = append(excludedExts, FrontendExts...) + } + cfg := &Config{ OutputPath: output, AppendMode: appendMd, @@ -136,10 +152,11 @@ func Parse() (*Config, error) { MaxSize: maxSize, MaxDepth: maxDepth, Ignores: append(DefaultIgnores, ignores...), - Extensions: append(DefaultExts, exts...), + Extensions: excludedExts, ProtonDrive: protonDrive, DrivePath: drivePath, VerticalSlices: verticalSlices, + SkipFrontend: skipFrontend, } if input != "" {