enhance dump --dump.format:json

This commit is contained in:
Timothee Cour
2018-12-09 21:45:15 -08:00
parent 606b43ba11
commit fc7b3a7c2a
2 changed files with 18 additions and 1 deletions

View File

@@ -266,11 +266,27 @@ proc mainCommand*(graph: ModuleGraph) =
var libpaths = newJArray()
for dir in conf.searchPaths: libpaths.elems.add(%dir.string)
var hints = block: # consider factoring with `listHints`
var ret = newJObject()
for a in hintMin..hintMax:
let key = lineinfos.HintsToStr[ord(a) - ord(hintMin)]
ret[key] = % (a in conf.notes)
ret
var warnings = block: # consider factoring with `listWarnings`
var ret = newJObject()
for a in warnMin..warnMax:
let key = lineinfos.WarningsToStr[ord(a) - ord(warnMin)]
ret[key] = % (a in conf.notes)
ret
var dumpdata = % [
(key: "version", val: %VersionAsString),
(key: "project_path", val: %conf.projectFull.string),
(key: "defined_symbols", val: definedSymbols),
(key: "lib_paths", val: libpaths)
(key: "lib_paths", val: %libpaths),
(key: "out", val: %conf.outFile.string),
(key: "hints", val: hints),
(key: "warnings", val: warnings),
]
msgWriteln(conf, $dumpdata, {msgStdout, msgSkipHook})

View File

@@ -13,6 +13,7 @@ Advanced commands:
//genDepend generate a DOT file containing the
module dependency graph
//dump dump all defined conditionals and search paths
see also: --dump.format:json (useful with: ` | jq`)
//check checks the project for syntax and semantic
Advanced options: