mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
* nix --query --expansion' (
-qe') to get any path with content
corresponding to the given id.
This commit is contained in:
parent
d84931ee56
commit
df648c4967
1 changed files with 13 additions and 3 deletions
16
src/nix.cc
16
src/nix.cc
|
@ -106,18 +106,19 @@ static void opAdd(Strings opFlags, Strings opArgs)
|
|||
/* Perform various sorts of queries. */
|
||||
static void opQuery(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
enum { qPaths, qRefs, qGenerators, qUnknown } query = qPaths;
|
||||
enum { qList, qRefs, qGenerators, qExpansion } query = qList;
|
||||
|
||||
for (Strings::iterator i = opFlags.begin();
|
||||
i != opFlags.end(); i++)
|
||||
if (*i == "--list" || *i == "-l") query = qPaths;
|
||||
if (*i == "--list" || *i == "-l") query = qList;
|
||||
else if (*i == "--refs" || *i == "-r") query = qRefs;
|
||||
else if (*i == "--generators" || *i == "-g") query = qGenerators;
|
||||
else if (*i == "--expansion" || *i == "-e") query = qExpansion;
|
||||
else throw UsageError(format("unknown flag `%1%'") % *i);
|
||||
|
||||
switch (query) {
|
||||
|
||||
case qPaths: {
|
||||
case qList: {
|
||||
StringSet paths;
|
||||
for (Strings::iterator i = opArgs.begin();
|
||||
i != opArgs.end(); i++)
|
||||
|
@ -159,6 +160,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
break;
|
||||
}
|
||||
|
||||
case qExpansion: {
|
||||
for (Strings::iterator i = opArgs.begin();
|
||||
i != opArgs.end(); i++)
|
||||
/* !!! should not use substitutes; this is a query,
|
||||
it should not have side-effects */
|
||||
cout << format("%s\n") % expandId(parseHash(*i));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue