From 292fb18f6ea33d40b2bf7218a064668a834616e6 Mon Sep 17 00:00:00 2001 From: aeneasr Date: Mon, 22 Oct 2018 19:34:17 -0700 Subject: [PATCH] tools: Add listx helper Signed-off-by: aeneasr --- tools/listx/main.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tools/listx/main.go diff --git a/tools/listx/main.go b/tools/listx/main.go new file mode 100644 index 00000000..174805cd --- /dev/null +++ b/tools/listx/main.go @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + "github.com/ory/x/cmdx" + "os" + "path/filepath" + "strings" +) + +func main() { + args := os.Args + if len(args) != 2 { + cmdx.Fatalf("Expects exactly one input parameter") + } + err := filepath.Walk(args[1], func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if info.IsDir() { + return nil + } + + if strings.Contains(path, "vendor") { + return nil + } + + if filepath.Ext(path) == ".go" { + if p, err := filepath.Abs(filepath.Join(args[1], path)); err != nil { + return err + } else { + fmt.Println(p) + } + } + + return nil + }) + + cmdx.Must(err, "%s", err) +}