feat: remove module command

This commit is contained in:
Rogee
2025-02-13 18:44:23 +08:00
parent e37cc85794
commit e2b09420a0
7 changed files with 159 additions and 14 deletions

View File

@@ -4,21 +4,21 @@ import (
"io/fs"
"os"
"path/filepath"
"regexp"
"strings"
"go.ipao.vip/atomctl/pkg/ast/route"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/pkg/ast/route"
"go.ipao.vip/atomctl/pkg/utils/gomod"
)
func CommandGenRoute(root *cobra.Command) {
cmd := &cobra.Command{
Use: "route",
Short: "generate routes",
RunE: commandGenRouteE,
PostRunE: commandGenProviderE,
Use: "route",
Short: "generate routes",
RunE: commandGenRouteE,
// PostRunE: commandGenProviderE,
}
root.AddCommand(cmd)
@@ -51,13 +51,20 @@ func commandGenRouteE(cmd *cobra.Command, args []string) error {
log.Fatal("modules dir not exist, ", modulePath)
}
controllerPattern := regexp.MustCompile(`controller(_?\w+)?\.go`)
// controllerPattern := regexp.MustCompile(`controller(_?\w+)?\.go`)
err = filepath.WalkDir(modulePath, func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
return nil
}
if !controllerPattern.MatchString(d.Name()) {
// if !controllerPattern.MatchString(d.Name()) {
// return nil
// }
if strings.HasSuffix(path, ".gen.go") {
return nil
}
if strings.HasSuffix(path, "_test.go") {
return nil
}