add omit md

This commit is contained in:
2026-08-27 14:42:00 +01:00
parent 2bbbf4e81e
commit a2afce3f8d
4 changed files with 22 additions and 1 deletions
+3
View File
@@ -69,6 +69,7 @@ Examples:
skipFrontend bool
frontendOnly bool
omitTest bool
omitMd bool
)
func Execute() {
@@ -92,6 +93,7 @@ func init() {
rootCmd.Flags().BoolVar(&skipFrontend, "skip-frontend", false, "omit frontend file types (.html, .css, .js, .ts, .vue, .svelte, etc.)")
rootCmd.Flags().BoolVar(&frontendOnly, "frontend-only", false, "include only frontend file types and README.md")
rootCmd.Flags().BoolVar(&omitTest, "omit-test", false, "exclude test files (Go *_test.go, Java *Test.java) and strip #[cfg(test)] blocks from Rust")
rootCmd.Flags().BoolVar(&omitMd, "omit-md", false, "omit all .md files except README.md")
rootCmd.MarkPersistentFlagRequired("output")
}
@@ -132,6 +134,7 @@ func run(cmd *cobra.Command, args []string) error {
SkipFrontend: skipFrontend,
FrontendOnly: frontendOnly,
OmitTest: omitTest,
OmitMd: omitMd,
}
if singleFile != "" {
+4
View File
@@ -81,6 +81,7 @@ type Config struct {
SkipFrontend bool
FrontendOnly bool
OmitTest bool
OmitMd bool
}
func PrintUsage() {
@@ -108,6 +109,7 @@ func Parse() (*Config, error) {
skipFrontend bool
frontendOnly bool
omitTest bool
omitMd bool
)
flag.StringVar(&input, "i", "", "single file input (append mode only)")
@@ -125,6 +127,7 @@ func Parse() (*Config, error) {
flag.BoolVar(&skipFrontend, "skip-frontend", false, "omit frontend file types (.html, .css, .js, .ts, .vue, .svelte, etc.)")
flag.BoolVar(&frontendOnly, "frontend-only", false, "include only frontend file types and README.md")
flag.BoolVar(&omitTest, "omit-test", false, "exclude test files (Go *_test.go, Java *Test.java) and strip #[cfg(test)] blocks from Rust")
flag.BoolVar(&omitMd, "omit-md", false, "omit all .md files except README.md")
flag.Usage = PrintUsage
flag.Parse()
@@ -173,6 +176,7 @@ func Parse() (*Config, error) {
SkipFrontend: skipFrontend,
FrontendOnly: frontendOnly,
OmitTest: omitTest,
OmitMd: omitMd,
}
if input != "" {
+13
View File
@@ -14,6 +14,7 @@ type Filter struct {
Ignores []string
OmitTest bool
FrontendOnly bool
OmitMd bool
}
func (f *Filter) ShouldSkipDir(name string) bool {
@@ -45,6 +46,10 @@ func (f *Filter) ShouldSkipFile(path, name string, info os.FileInfo) bool {
return true
}
if f.OmitMd && isNonReadmeMarkdown(path, name) {
return true
}
if f.FrontendOnly && !isFrontendOrReadme(path, name) {
return true
}
@@ -63,6 +68,14 @@ func (f *Filter) ShouldSkipFile(path, name string, info os.FileInfo) bool {
return false
}
func isNonReadmeMarkdown(path, name string) bool {
ext := strings.ToLower(filepath.Ext(path))
if ext != ".md" && ext != ".markdown" {
return false
}
return !strings.EqualFold(name, "README.md")
}
func isFrontendOrReadme(path, name string) bool {
ext := strings.ToLower(filepath.Ext(path))
for _, fe := range config.FrontendExts {
+2 -1
View File
@@ -1,4 +1,3 @@
// internal/walker/walker.go
package walker
import (
@@ -47,6 +46,7 @@ func processSingleFile(cfg *config.Config) (*Result, error) {
Ignores: cfg.Ignores,
OmitTest: cfg.OmitTest,
FrontendOnly: cfg.FrontendOnly,
OmitMd: cfg.OmitMd,
}
if flt.ShouldSkipFile(cfg.AbsRoot, filepath.Base(cfg.AbsRoot), info) {
@@ -68,6 +68,7 @@ func walkDirectory(cfg *config.Config) (*Result, error) {
Ignores: cfg.Ignores,
OmitTest: cfg.OmitTest,
FrontendOnly: cfg.FrontendOnly,
OmitMd: cfg.OmitMd,
}
result := &Result{AbsRoot: cfg.AbsRoot, OmitTest: cfg.OmitTest}