Skip to content

Commit

Permalink
tools: Add listx helper
Browse files Browse the repository at this point in the history
Signed-off-by: aeneasr <aeneas.rekkas@serlo.org>
  • Loading branch information
aeneasr committed Oct 23, 2018
1 parent 57919ad commit 292fb18
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tools/listx/main.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 292fb18

Please sign in to comment.