Closed aik099 closed 8 years ago
You can use the -oneline option, it outputs matches in a normalized form: one line per match. It's not Json but it's very easy to parse. There is actually also a -gen_layer foo.json option, to generate a JSON file containing the list of matches, but the format of this JSON is oriented towards code visualization (see https://github.com/facebook/pfff/blob/master/h_program-lang/layer_code.ml )
The -online
option is perfect. It also does join matched multi-line statements into 1 line.
Right now sgrep outputs data in human readable, but not machine parseable format. Are there any changes to add support for different formats e.g.
xml
orjson
?For now I'll search for
text:number
lines (wheretext
must be full path to a file) to identify file lines and all following lines till next such occurrence will be used as matched code fragment.What I wanted to have is a way to use
sgrep
on a Build Server to fail a build, when problematic code was found.