about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-05-01T11·30+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-05-01T11·30+0000
commitbd1f66453a7a1900f9fa850a7052b3fbe3e26933 (patch)
tree1cb7c1c392f61fd6fecb1b84d87df2bd4c782fd8
parente20f0da22ccb28d94bfd82fa66e2a723c75951f2 (diff)
* `nix-env -q --xml --meta' to show all meta attributes.
-rw-r--r--doc/manual/release-notes.xml4
-rw-r--r--src/nix-env/help.txt3
-rw-r--r--src/nix-env/nix-env.cc15
3 files changed, 19 insertions, 3 deletions
diff --git a/doc/manual/release-notes.xml b/doc/manual/release-notes.xml
index 3b4525129d..da8c47588b 100644
--- a/doc/manual/release-notes.xml
+++ b/doc/manual/release-notes.xml
@@ -67,8 +67,8 @@
 
 
   <listitem><para>TODO: <command>nix-env</command> now maintains meta
-  info about installed packages in user
-  environments.</para></listitem>
+  info about installed packages in user environments.  <option>-q
+  --xml --meta</option> to show all meta info.</para></listitem>
 
   <listitem><para>TODO: <command>nix-env</command>
   <option>--set-flag</option>.  Specific flags:
diff --git a/src/nix-env/help.txt b/src/nix-env/help.txt
index 16e47a73e3..b10c4b4924 100644
--- a/src/nix-env/help.txt
+++ b/src/nix-env/help.txt
@@ -52,6 +52,7 @@ Query sources:
 
 Query flags:
 
+  --xml: show output in XML format
   --status / -s: print installed/present status
   --no-name: hide derivation names
   --attr / -A: shows the unambiguous attribute name of the
@@ -60,6 +61,8 @@ Query flags:
   --compare-versions / -c: compare version to available or installed
   --drv-path: print path of derivation
   --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
       available on this machine or are downloadable
 
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 3eea5c0c55..9f965bd287 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -836,6 +836,7 @@ static void opQuery(Globals & globals,
     bool printDrvPath = false;
     bool printOutPath = false;
     bool printDescription = false;
+    bool printMeta = false;
     bool prebuiltOnly = false;
     bool compareVersions = 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 == "--drv-path") printDrvPath = true;
         else if (*i == "--out-path") printOutPath = true;
+        else if (*i == "--meta") printMeta = true;
         else if (*i == "--installed") source = sInstalled;
         else if (*i == "--available" || *i == "-a") source = sAvailable;
         else if (*i == "--prebuilt-only" || *i == "-b") prebuiltOnly = true;
@@ -1014,7 +1016,18 @@ static void opQuery(Globals & globals,
             }
 
             if (xmlOutput)
-                xml.writeEmptyElement("item", attrs);
+                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);
             else
                 table.push_back(columns);