1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

Merge pull request #5942 from NixOS/5912-quieter-nix-why-depends

Make `nix why-depends` quieter by default
This commit is contained in:
Eelco Dolstra 2022-01-21 10:18:28 +01:00 committed by GitHub
commit c7223db871
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 10 deletions

View file

@ -31,6 +31,7 @@ struct CmdWhyDepends : SourceExprCommand
{
std::string _package, _dependency;
bool all = false;
bool precise = false;
CmdWhyDepends()
{
@ -56,6 +57,12 @@ struct CmdWhyDepends : SourceExprCommand
.description = "Show all edges in the dependency graph leading from *package* to *dependency*, rather than just a shortest path.",
.handler = {&all, true},
});
addFlag({
.longName = "precise",
.description = "For each edge in the dependency graph, show the files in the parent that cause the dependency.",
.handler = {&precise, true},
});
}
std::string description() override
@ -158,11 +165,19 @@ struct CmdWhyDepends : SourceExprCommand
auto pathS = store->printStorePath(node.path);
assert(node.dist != inf);
logger->cout("%s%s%s%s" ANSI_NORMAL,
firstPad,
node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? "" : "",
pathS);
if (precise) {
logger->cout("%s%s%s%s" ANSI_NORMAL,
firstPad,
node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? "" : "",
pathS);
} else {
logger->cout("%s%s%s%s" ANSI_NORMAL,
firstPad,
node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? treeLast : "",
pathS);
}
if (node.path == dependencyPath && !all
&& packagePath != dependencyPath)
@ -237,7 +252,7 @@ struct CmdWhyDepends : SourceExprCommand
// FIXME: should use scanForReferences().
visitPath(pathS);
if (precise) visitPath(pathS);
for (auto & ref : refs) {
std::string hash(ref.second->path.hashPart());