1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-25 17:45:39 +00:00

Merge pull request #66 from vbatts/list_used_JSON

gomtree: `-list-used` can output JSON
This commit is contained in:
Vincent Batts 2016-08-11 15:00:19 -04:00 committed by GitHub
commit 52985ee3a5

View file

@ -164,13 +164,26 @@ func main() {
isErr = true isErr = true
return return
} }
fmt.Printf("Keywords used in [%s]:\n", *flFile) usedKeywords := mtree.CollectUsedKeywords(dh)
for _, kw := range mtree.CollectUsedKeywords(dh) { if *flResultFormat == "json" {
fmt.Printf(" %s", kw) // if they're asking for json, give it to them
if _, ok := mtree.KeywordFuncs[kw]; !ok { data := map[string][]string{*flFile: usedKeywords}
fmt.Print(" (unsupported)") buf, err := json.MarshalIndent(data, "", " ")
if err != nil {
defer os.Exit(1)
isErr = true
return
}
fmt.Println(string(buf))
} else {
fmt.Printf("Keywords used in [%s]:\n", *flFile)
for _, kw := range usedKeywords {
fmt.Printf(" %s", kw)
if _, ok := mtree.KeywordFuncs[kw]; !ok {
fmt.Print(" (unsupported)")
}
fmt.Printf("\n")
} }
fmt.Printf("\n")
} }
return return
} }