From 4a2511bb0089458eef3b78acc0f1dbc264c9c15a Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Oct 29 2023 11:44:13 +0000 Subject: Exclude .md files by default Close: #32 --- diff --git a/cmd/golist/golist.go b/cmd/golist/golist.go index a32066c..bf1d5d2 100644 --- a/cmd/golist/golist.go +++ b/cmd/golist/golist.go @@ -17,7 +17,7 @@ import ( ) var ( - version = "0.10.3" + version = "0.10.4" ) func main() { @@ -75,6 +75,10 @@ func main() { Name: "to-install", Usage: "List all resources recognized as essential part of the Go project", }, + cli.BoolFlag{ + Name: "include-md", + Usage: "Include Markdown (.md) files in the recognized resources", + }, cli.StringSliceFlag{ Name: "include-extension, e", Usage: "Include all files with the extension in the recognized resources, e.g. .proto, .tmpl", @@ -136,7 +140,7 @@ func main() { ignore.Regexes = append(ignore.Regexes, regexp.MustCompile(dir)) } - collector := util.NewPackageInfoCollector(ignore, c.StringSlice("include-extension")) + collector := util.NewPackageInfoCollector(ignore, c.Bool("include-md"), c.StringSlice("include-extension")) for _, packagePath := range c.StringSlice("package-path") { if err := collector.CollectPackageInfos(packagePath); err != nil { return err diff --git a/pkg/util/util.go b/pkg/util/util.go index 4b54429..35ed62f 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -69,6 +69,7 @@ type PackageInfoCollector struct { mainFiles map[string][]string packagePath string ignore *Ignore + includeMD bool extensions []string otherResources *OtherResources isStdPackages map[string]bool @@ -82,12 +83,13 @@ type OtherResources struct { Other []string } -func NewPackageInfoCollector(ignore *Ignore, extensions []string) *PackageInfoCollector { +func NewPackageInfoCollector(ignore *Ignore, includeMD bool, extensions []string) *PackageInfoCollector { return &PackageInfoCollector{ packageInfos: make(map[string]*build.Package), mainFiles: make(map[string][]string), isStdPackages: make(map[string]bool), ignore: ignore, + includeMD: includeMD, extensions: extensions, } } @@ -283,7 +285,7 @@ func (p *PackageInfoCollector) CollectInstalledResources() ([]string, error) { if p.otherResources.ProtoFiles != nil { resources = append(resources, p.otherResources.ProtoFiles...) } - if p.otherResources.MDFiles != nil { + if p.includeMD && p.otherResources.MDFiles != nil { resources = append(resources, p.otherResources.MDFiles...) } if p.otherResources.SFiles != nil {