aboutsummaryrefslogtreecommitdiff
path: root/src/nix/why-depends.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/why-depends.cc')
-rw-r--r--src/nix/why-depends.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc
index dd43bd1c3..74377c912 100644
--- a/src/nix/why-depends.cc
+++ b/src/nix/why-depends.cc
@@ -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 of the graph, inspect the parent node to display the exact location in the path that causes 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());