Skip to content

Commit

Permalink
cmd/grepfunc: add verbose mode
Browse files Browse the repository at this point in the history
Print gogrep pattern if verbose mode is on.

Signed-off-by: Iskander Sharipov <[email protected]>
  • Loading branch information
quasilyte committed Jan 25, 2019
1 parent 3b22cb7 commit 0e169c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/grepfunc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func main() {
`input Go file with pattern function`)
pattern := flag.String("pattern", "_pattern",
`function to be interpreted as a pattern`)
verbose := flag.Bool("v", false,
`turn on debug output`)
flag.Parse()

if *input == "" {
Expand Down Expand Up @@ -52,6 +54,10 @@ func main() {
s = strings.TrimPrefix(s, "{")
s = strings.TrimSuffix(s, "}")

if *verbose {
fmt.Println(s)
}

gogrepArgs := []string{"-x", s}
gogrepArgs = append(gogrepArgs, targets...)
out, err := exec.Command("gogrep", gogrepArgs...).CombinedOutput()
Expand Down

0 comments on commit 0e169c2

Please sign in to comment.