Add compact mode, toggle with 'c'
This commit is contained in:
@ -50,12 +50,14 @@ class TreeList implements Countable
|
||||
foreach ($node->items as $item) {
|
||||
$this->parseNode($item, [ ...$path, $key ], $index++);
|
||||
}
|
||||
$this->list[$entryKey.'$'] = new Entry(depth: $level, key: $key, node: $node, closer: true);
|
||||
if (!Settings::$compactGroups)
|
||||
$this->list[$entryKey.'$'] = new Entry(depth: $level, key: $key, node: $node, closer: true);
|
||||
} elseif ($node instanceof ObjectNode) {
|
||||
foreach ($node->properties as $nodekey=>$item) {
|
||||
$this->parseNode($item, [ ...$path, $key ], $nodekey);
|
||||
}
|
||||
$this->list[$entryKey.'$'] = new Entry(depth: $level, key: $key, node: $node, closer: true);
|
||||
if (!Settings::$compactGroups)
|
||||
$this->list[$entryKey.'$'] = new Entry(depth: $level, key: $key, node: $node, closer: true);
|
||||
|
||||
}
|
||||
}
|
||||
@ -150,11 +152,13 @@ class TreeList implements Countable
|
||||
echo "\e[90m".str_repeat("\u{258f} ",$entry->depth)."\e[37m";
|
||||
|
||||
if ($entry->closer) {
|
||||
if ($entry->node instanceof ArrayNode) {
|
||||
echo "]";
|
||||
} elseif ($entry->node instanceof ObjectNode) {
|
||||
echo "}";
|
||||
}
|
||||
if (!Settings::$compactGroups) {
|
||||
if ($entry->node instanceof ArrayNode) {
|
||||
echo "]";
|
||||
} elseif ($entry->node instanceof ObjectNode) {
|
||||
echo "}";
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -167,9 +171,9 @@ class TreeList implements Countable
|
||||
));
|
||||
}
|
||||
if ($entry->node instanceof ArrayNode) {
|
||||
echo "[";
|
||||
echo "[" . (Settings::$compactGroups ? "…]":"");
|
||||
} elseif ($entry->node instanceof ObjectNode) {
|
||||
echo "{";
|
||||
echo "{" . (Settings::$compactGroups ? "…}":"");
|
||||
} elseif ($entry->node instanceof ValueNode) {
|
||||
$value = $entry->node->value;
|
||||
echo match (gettype($value)) {
|
||||
|
Reference in New Issue
Block a user