Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Console] Add a Tree Helper + multiple Styles#59588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I like it!
Memory consumption should be considered as this deals with potentially large directories, ideally nodes should be yielded as they come.
Regarding the public API, we should remove or internalize any getter/setter for which we don't have a strong use case.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Yep! I'll make the changes depending on the following questions.
Do you have some examples in mind ? Do we need both |
I was refering to |
smnandre commentedJan 26, 2025 • edited by OskarStark
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by OskarStark
Uh oh!
There was an error while loading.Please reload this page.
I've removed the getters and added a "appy" method on TreeStyle (we can consider publicfunctionapplyPrefixes(RecursiveTreeIterator$iterator):void{$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_LEFT,$this->prefixLeft);$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_MID_HAS_NEXT,$this->prefixMidHasNext);$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_MID_LAST,$this->prefixMidLast);$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_END_HAS_NEXT,$this->prefixEndHasNext);$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_END_LAST,$this->prefixEndLast);$iterator->setPrefixPart(RecursiveTreeIterator::PREFIX_RIGHT,$this->prefixRight);} Also removed getStyle / setStyle Will refactor as lazy iterator but i'm not sure how to handle the cycles yet |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
chadyred commentedJan 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@smnandre It will be really useful 🙏 great job |
Uh oh!
There was an error while loading.Please reload this page.
e4e66de
to5ffb3fd
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
💯
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
smnandre commentedFeb 9, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I've fusioned Removed the Finder integration for now (i'd rather have separated PR as it will require some discussion) |
Open to review :) |
@@ -369,6 +373,24 @@ private function getProgressBar(): ProgressBar | |||
?? throw new RuntimeException('The ProgressBar is not started.'); | |||
} | |||
/** | |||
* @param iterable<string, iterable|string|TreeNode> $nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Some words or example about what can be passed would be nice either here or in TreeHelper or both
chadyredFeb 10, 2025 • edited by OskarStark
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by OskarStark
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
HA ! It is to avoid back and forth (with a future link to the doc) :), a sample like :
$treeHelper =newTreeHelper($output, TreeNode::fromValues(['a' => ['a1','a2'],'b','c' => ['c1','c2' => ['c21' => ['c211','c212', ], ],],],newTreeNode($rootNode),), TreeStyle::rounded());$treeHelper->render();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A few comments but looks good otherwise 🙂
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
$parent->addChild($this); | ||
} | ||
foreach ($children as $child) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
iterating in the constructor breaks lazy evaluation of the iterable, is that justified?
public static function box(): self | ||
{ | ||
return new self( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
on one line things would be better visually - not consuming my screen's space for nothing ;)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Last comments are none blocking suggestion |
177f738
to6a641c9
CompareThank you@smnandre. |
5c29eec
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
This PR was squashed before being merged into the 7.3 branch.Discussion----------[Console] Document the `TreeHelper`| Q | A || - | - || Feature PR | [symfony/symfony#59588](symfony/symfony#59588) || PR author(s) | [`@smnandre`](https://github.com/smnandre) || Merged in | 7.3 || Doc Issue |Fix#20692 |fix#20692Commits-------d9a48be [Console] Document the `TreeHelper`
Uh oh!
There was an error while loading.Please reload this page.
Important
Code examples below arenot up to date, documentation incoming.
Feature
The goal of the Tree helper is to ease renderinghierarchical data in the console:
Usage
Two methods available, manual or via SymfonyStyle
SymfonyStyle (easiest)
Will render
You also can pass a custom TreeStyle here, or one of the one availbes (see below)
Manually
You can build the Tree the way you want thanks to the TreeNode class.
Styles
Various styles are available (based on the styles of Table .. and some new ones), or you can also build your own Style from scratch.
Default
Box
Box Double
Rounded
Compact
Light
Minimal