*: add --result-format=json format
This is far easier to parse than the default raw format, and provides the full serialised result structure. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
8cf7253132
commit
692f56a830
2 changed files with 15 additions and 5 deletions
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
@ -30,6 +31,14 @@ var formats = map[string]func(*mtree.Result) string{
|
|||
}
|
||||
return buffer.String()
|
||||
},
|
||||
|
||||
"json": func(r *mtree.Result) string {
|
||||
var buffer bytes.Buffer
|
||||
if err := json.NewEncoder(&buffer).Encode(r); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return buffer.String()
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue