Skip to content

Commit c926a3f

Browse files
eyechoirsjgautheron
eyechoirs
authored andcommitted
Add flag to print single line per match
1 parent ccae5bf commit c926a3f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/goconst/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Flags:
3030
-max maximum value, only works with -numbers
3131
-output output formatting (text or json)
3232
-set-exit-status Set exit status to 2 if any issues are found
33+
-grouped print single line per match, only works with -output text
3334
3435
Examples:
3536
@@ -50,6 +51,7 @@ var (
5051
flagMax = flag.Int("max", 0, "maximum value, only works with -numbers")
5152
flagOutput = flag.String("output", "text", "output formatting")
5253
flagSetExitStatus = flag.Bool("set-exit-status", false, "Set exit status to 2 if any issues are found")
54+
flagGrouped = flag.Bool("grouped", false, "print single line per match, only works with -output text")
5355
)
5456

5557
func main() {
@@ -134,6 +136,10 @@ func printOutput(strs goconst.Strings, consts goconst.Constants, output string)
134136
occurrences(item, xpos),
135137
)
136138
fmt.Print("\n")
139+
140+
if *flagGrouped {
141+
break
142+
}
137143
}
138144

139145
if len(consts) == 0 {

0 commit comments

Comments
 (0)