mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Add outputs to JSON query
Emit output information when printing JSON information and `--out-paths` is requested. fixes #5877
This commit is contained in:
parent
bdc577936f
commit
65257614ea
1 changed files with 10 additions and 2 deletions
|
@ -907,7 +907,7 @@ static VersionDiff compareVersionAgainstSet(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void queryJSON(Globals & globals, vector<DrvInfo> & elems)
|
static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutPath)
|
||||||
{
|
{
|
||||||
JSONObject topObj(cout, true);
|
JSONObject topObj(cout, true);
|
||||||
for (auto & i : elems) {
|
for (auto & i : elems) {
|
||||||
|
@ -919,6 +919,14 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems)
|
||||||
pkgObj.attr("version", drvName.version);
|
pkgObj.attr("version", drvName.version);
|
||||||
pkgObj.attr("system", i.querySystem());
|
pkgObj.attr("system", i.querySystem());
|
||||||
|
|
||||||
|
if (printOutPath) {
|
||||||
|
DrvInfo::Outputs outputs = i.queryOutputs();
|
||||||
|
JSONObject outputObj = pkgObj.object("outputs");
|
||||||
|
for (auto & j : outputs) {
|
||||||
|
outputObj.attr(j.first, j.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JSONObject metaObj = pkgObj.object("meta");
|
JSONObject metaObj = pkgObj.object("meta");
|
||||||
StringSet metaNames = i.queryMetaNames();
|
StringSet metaNames = i.queryMetaNames();
|
||||||
for (auto & j : metaNames) {
|
for (auto & j : metaNames) {
|
||||||
|
@ -1035,7 +1043,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
/* Print the desired columns, or XML output. */
|
/* Print the desired columns, or XML output. */
|
||||||
if (jsonOutput) {
|
if (jsonOutput) {
|
||||||
queryJSON(globals, elems);
|
queryJSON(globals, elems, printOutPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue