* `nix-env -q --xml --meta' to show all meta attributes.

This commit is contained in:
Eelco Dolstra 2007-05-01 11:30:52 +00:00
parent e20f0da22c
commit bd1f66453a
3 changed files with 19 additions and 3 deletions

View file

@ -67,8 +67,8 @@
<listitem><para>TODO: <command>nix-env</command> now maintains meta <listitem><para>TODO: <command>nix-env</command> now maintains meta
info about installed packages in user info about installed packages in user environments. <option>-q
environments.</para></listitem> --xml --meta</option> to show all meta info.</para></listitem>
<listitem><para>TODO: <command>nix-env</command> <listitem><para>TODO: <command>nix-env</command>
<option>--set-flag</option>. Specific flags: <option>--set-flag</option>. Specific flags:

View file

@ -52,6 +52,7 @@ Query sources:
Query flags: Query flags:
--xml: show output in XML format
--status / -s: print installed/present status --status / -s: print installed/present status
--no-name: hide derivation names --no-name: hide derivation names
--attr / -A: shows the unambiguous attribute name of the --attr / -A: shows the unambiguous attribute name of the
@ -60,6 +61,8 @@ Query flags:
--compare-versions / -c: compare version to available or installed --compare-versions / -c: compare version to available or installed
--drv-path: print path of derivation --drv-path: print path of derivation
--out-path: print path of derivation output --out-path: print path of derivation output
--description: print description
--meta: print all meta attributes (only with --xml)
--prebuilt-only: only show derivations whose prebuilt binaries are --prebuilt-only: only show derivations whose prebuilt binaries are
available on this machine or are downloadable available on this machine or are downloadable

View file

@ -836,6 +836,7 @@ static void opQuery(Globals & globals,
bool printDrvPath = false; bool printDrvPath = false;
bool printOutPath = false; bool printOutPath = false;
bool printDescription = false; bool printDescription = false;
bool printMeta = false;
bool prebuiltOnly = false; bool prebuiltOnly = false;
bool compareVersions = false; bool compareVersions = false;
bool xmlOutput = false; bool xmlOutput = false;
@ -853,6 +854,7 @@ static void opQuery(Globals & globals,
else if (*i == "--compare-versions" || *i == "-c") compareVersions = true; else if (*i == "--compare-versions" || *i == "-c") compareVersions = true;
else if (*i == "--drv-path") printDrvPath = true; else if (*i == "--drv-path") printDrvPath = true;
else if (*i == "--out-path") printOutPath = true; else if (*i == "--out-path") printOutPath = true;
else if (*i == "--meta") printMeta = true;
else if (*i == "--installed") source = sInstalled; else if (*i == "--installed") source = sInstalled;
else if (*i == "--available" || *i == "-a") source = sAvailable; else if (*i == "--available" || *i == "-a") source = sAvailable;
else if (*i == "--prebuilt-only" || *i == "-b") prebuiltOnly = true; else if (*i == "--prebuilt-only" || *i == "-b") prebuiltOnly = true;
@ -1014,6 +1016,17 @@ static void opQuery(Globals & globals,
} }
if (xmlOutput) if (xmlOutput)
if (printMeta) {
XMLOpenElement item(xml, "item", attrs);
MetaInfo meta = i->queryMetaInfo(globals.state);
for (MetaInfo::iterator j = meta.begin(); j != meta.end(); ++j) {
XMLAttrs attrs2;
attrs2["name"] = j->first;
attrs2["value"] = j->second;
xml.writeEmptyElement("meta", attrs2);
}
}
else
xml.writeEmptyElement("item", attrs); xml.writeEmptyElement("item", attrs);
else else
table.push_back(columns); table.push_back(columns);