add omit md
This commit is contained in:
@@ -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 != "" {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user