forked from lix-project/lix
nix-store.cc: Refactor, remove qDefault
This commit is contained in:
parent
fba7be80eb
commit
bf2c5c3958
|
@ -277,17 +277,17 @@ static void printTree(const StorePath & path,
|
||||||
static void opQuery(Strings opFlags, Strings opArgs)
|
static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
enum QueryType
|
enum QueryType
|
||||||
{ qDefault, qOutputs, qRequisites, qReferences, qReferrers
|
{ qOutputs, qRequisites, qReferences, qReferrers
|
||||||
, qReferrersClosure, qDeriver, qBinding, qHash, qSize
|
, qReferrersClosure, qDeriver, qBinding, qHash, qSize
|
||||||
, qTree, qGraph, qGraphML, qResolve, qRoots };
|
, qTree, qGraph, qGraphML, qResolve, qRoots };
|
||||||
QueryType query = qDefault;
|
std::optional<QueryType> query;
|
||||||
bool useOutput = false;
|
bool useOutput = false;
|
||||||
bool includeOutputs = false;
|
bool includeOutputs = false;
|
||||||
bool forceRealise = false;
|
bool forceRealise = false;
|
||||||
std::string bindingName;
|
std::string bindingName;
|
||||||
|
|
||||||
for (auto & i : opFlags) {
|
for (auto & i : opFlags) {
|
||||||
QueryType prev = query;
|
std::optional<QueryType> prev = query;
|
||||||
if (i == "--outputs") query = qOutputs;
|
if (i == "--outputs") query = qOutputs;
|
||||||
else if (i == "--requisites" || i == "-R") query = qRequisites;
|
else if (i == "--requisites" || i == "-R") query = qRequisites;
|
||||||
else if (i == "--references") query = qReferences;
|
else if (i == "--references") query = qReferences;
|
||||||
|
@ -312,15 +312,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
else if (i == "--force-realise" || i == "--force-realize" || i == "-f") forceRealise = true;
|
else if (i == "--force-realise" || i == "--force-realize" || i == "-f") forceRealise = true;
|
||||||
else if (i == "--include-outputs") includeOutputs = true;
|
else if (i == "--include-outputs") includeOutputs = true;
|
||||||
else throw UsageError("unknown flag '%1%'", i);
|
else throw UsageError("unknown flag '%1%'", i);
|
||||||
if (prev != qDefault && prev != query)
|
if (prev && prev != query)
|
||||||
throw UsageError("query type '%1%' conflicts with earlier flag", i);
|
throw UsageError("query type '%1%' conflicts with earlier flag", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query == qDefault) query = qOutputs;
|
if (!query) query = qOutputs;
|
||||||
|
|
||||||
RunPager pager;
|
RunPager pager;
|
||||||
|
|
||||||
switch (query) {
|
switch (*query) {
|
||||||
|
|
||||||
case qOutputs: {
|
case qOutputs: {
|
||||||
for (auto & i : opArgs) {
|
for (auto & i : opArgs) {
|
||||||
|
@ -443,7 +443,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: case qDefault:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue