Skip to content

Commit

Permalink
no recurse by default
Browse files Browse the repository at this point in the history
  • Loading branch information
drshriveer committed Sep 28, 2023
1 parent f4ce93f commit 44cb5cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions gogenproto/cmd/gogenproto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"flag"
"log"

"github.com/itzg/go-flagsfiller"

Expand All @@ -18,6 +17,6 @@ func main() {
flag.Parse()

if err := g.Run(); err != nil {
log.Fatalf("run failed: %+v", err)
gen.Logger.Fatalf("run failed: %+v", err)
}
}
9 changes: 7 additions & 2 deletions gogenproto/gen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var Logger = log.New(log.Writer(), "[gogenproto] ", log.LstdFlags)
type Generate struct {
InputDir string `alias:"inputDir" env:"PWD" usage:"path to root directory for proto generation"`
OutputDir string `alias:"outputDir" default:"../" usage:"relative output path for generated files"`

Recurse bool `alias:"recurse" default:"false" usage:"generate protos recursively"`
// TODO: other flags, like VTProto, GRPC, TS, etc,
}

Expand All @@ -43,9 +45,12 @@ func (g Generate) findProtos() ([]string, error) {
protoList := []string{}
err := filepath.WalkDir(g.InputDir,
func(pathname string, d fs.DirEntry, err error) error {
if err != nil || pathname == "." {
if err != nil || pathname == "." || pathname == g.InputDir {
return err
} else if d.Type().IsRegular() {
} else if d.IsDir() && !g.Recurse {
return fs.SkipDir
}
if d.Type().IsRegular() {
if filepath.Ext(d.Name()) == ".proto" {
protoList = append(protoList, pathname)
}
Expand Down
9 changes: 9 additions & 0 deletions gogenproto/internal/skipped/should_be_skipped.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

package gtools.gogenproto.internal.skipped;

option go_package = "internal/skipped";

message ShouldBeSkipped{
int32 f = 1;
}

0 comments on commit 44cb5cd

Please sign in to comment.