mirror of
https://github.com/NixOS/nix.git
synced 2025-12-02 15:11:00 +01:00
nix flake list-inputs: Pretty-print the tree
This commit is contained in:
parent
a6e2b6b360
commit
678301072f
5 changed files with 54 additions and 25 deletions
|
|
@ -229,12 +229,6 @@ static StorePathSet maybeUseOutputs(const StorePath & storePath, bool useOutput,
|
|||
/* Some code to print a tree representation of a derivation dependency
|
||||
graph. Topological sorting is used to keep the tree relatively
|
||||
flat. */
|
||||
|
||||
const string treeConn = "+---";
|
||||
const string treeLine = "| ";
|
||||
const string treeNull = " ";
|
||||
|
||||
|
||||
static void printTree(const StorePath & path,
|
||||
const string & firstPad, const string & tailPad, StorePathSet & done)
|
||||
{
|
||||
|
|
@ -254,10 +248,11 @@ static void printTree(const StorePath & path,
|
|||
auto sorted = store->topoSortPaths(info->references);
|
||||
reverse(sorted.begin(), sorted.end());
|
||||
|
||||
for (auto i = sorted.begin(); i != sorted.end(); ++i) {
|
||||
auto j = i; ++j;
|
||||
printTree(*i, tailPad + treeConn,
|
||||
j == sorted.end() ? tailPad + treeNull : tailPad + treeLine,
|
||||
for (const auto &[n, i] : enumerate(sorted)) {
|
||||
bool last = n + 1 == sorted.size();
|
||||
printTree(i,
|
||||
tailPad + (last ? treeLast : treeConn),
|
||||
tailPad + (last ? treeNull : treeLine),
|
||||
done);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue