mirror of
https://github.com/vbatts/tar-split.git
synced 2024-11-16 13:28:37 +00:00
Merge pull request #66 from vbatts/list_used_JSON
gomtree: `-list-used` can output JSON
This commit is contained in:
commit
52985ee3a5
1 changed files with 19 additions and 6 deletions
|
@ -164,14 +164,27 @@ func main() {
|
||||||
isErr = true
|
isErr = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
usedKeywords := mtree.CollectUsedKeywords(dh)
|
||||||
|
if *flResultFormat == "json" {
|
||||||
|
// if they're asking for json, give it to them
|
||||||
|
data := map[string][]string{*flFile: usedKeywords}
|
||||||
|
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)
|
fmt.Printf("Keywords used in [%s]:\n", *flFile)
|
||||||
for _, kw := range mtree.CollectUsedKeywords(dh) {
|
for _, kw := range usedKeywords {
|
||||||
fmt.Printf(" %s", kw)
|
fmt.Printf(" %s", kw)
|
||||||
if _, ok := mtree.KeywordFuncs[kw]; !ok {
|
if _, ok := mtree.KeywordFuncs[kw]; !ok {
|
||||||
fmt.Print(" (unsupported)")
|
fmt.Print(" (unsupported)")
|
||||||
}
|
}
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue