From 0e169c2a01fa6c9618835247c2ee4a81f9167f0e Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Fri, 25 Jan 2019 08:12:48 +0300 Subject: [PATCH] cmd/grepfunc: add verbose mode Print gogrep pattern if verbose mode is on. Signed-off-by: Iskander Sharipov --- cmd/grepfunc/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/grepfunc/main.go b/cmd/grepfunc/main.go index fff4b6b..e66db19 100644 --- a/cmd/grepfunc/main.go +++ b/cmd/grepfunc/main.go @@ -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 == "" { @@ -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()