diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-01-06 22:33:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 22:33:11 +0100 |
commit | 5c7d3b351ff386e4864261b34b138d5b39d958b6 (patch) | |
tree | b74e399140940d53b2e2b56f91b710bf8f787fcf | |
parent | 3ec02c6743e4863bea1dfc3ea39a7ee72e0e83c7 (diff) | |
parent | 65257614ea77437a75447c3b5936f240e581ede9 (diff) |
Merge pull request #5878 from fzakaria/faridzakaria/json-outputs
Add outputs to JSON query
-rw-r--r-- | src/nix-env/nix-env.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index f64075567..b2d789324 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -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); for (auto & i : elems) { @@ -919,6 +919,14 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems) pkgObj.attr("version", drvName.version); 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"); StringSet metaNames = i.queryMetaNames(); for (auto & j : metaNames) { @@ -1035,7 +1043,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) /* Print the desired columns, or XML output. */ if (jsonOutput) { - queryJSON(globals, elems); + queryJSON(globals, elems, printOutPath); return; } |