about summary refs log tree commit diff
path: root/src/nix-instantiate
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-07-28T14·01+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-07-28T14·01+0000
commitc11839d7b24993f9639d59f9fa3420e8ccc22e02 (patch)
tree624ef0a1ceb8fc9946da438e4899a5cfe1f3c818 /src/nix-instantiate
parentca2238cf818e27ebb663c83a9fe9ae7f58eb830f (diff)
* `nix-instantiate --print-args': print out the valid values for
  functions arguments that have a domain.

Diffstat (limited to 'src/nix-instantiate')
-rw-r--r--src/nix-instantiate/main.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/nix-instantiate/main.cc b/src/nix-instantiate/main.cc
index 963e81bac4f7..857aeaa24798 100644
--- a/src/nix-instantiate/main.cc
+++ b/src/nix-instantiate/main.cc
@@ -44,9 +44,17 @@ static void printResult(EvalState & state, Expr e,
         ATerm body, pos;
         if (matchFunction(e, formals, body, pos)) {
             for (ATermIterator i(formals); i; ++i) {
-                Expr name; ATerm d1, d2;
-                if (!matchFormal(*i, name, d1, d2)) abort();
-                cout << format("%1%\n") % aterm2String(name);
+                Expr name; ValidValues valids; ATerm dummy;
+                if (!matchFormal(*i, name, valids, dummy)) abort();
+                cout << format("%1%: ") % aterm2String(name);
+                ATermList valids2;
+                if (matchValidValues(valids, valids2)) {
+                    for (ATermIterator j(valids2); j; ++j) {
+                        Expr e = evalExpr(state, *j);
+                        cout << format("%1% ") % showValue(e);
+                    }
+                }
+                cout << format("\n");
             }
         } else
             printMsg(lvlError, "warning: expression does not evaluate to a function");