-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Added support for definition list and horizontal table #32742
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a31ec13
to
332f318
Compare
dda6c0c
to
034bef5
Compare
I would change the proposed usage by the following: $io->table(['a', 'b', 'c'], [[1, 2, 3], [4, 5, 6]]);
$io->horizontalTable(['a', 'b', 'c'], [[1, 2, 3], [4, 5, 6]]);
$io->horizontalTable(['id', 'title', 'foo'], [[123, 'My title', 'bar']]); The boolean param of What if I have an associative array with the "definition list" information? do this: $io->horizontalTable(array_keys($foo), [array_values($foo)]); |
Actually, it's way easier to write: $io->definitonList(['title' => 'value', 'title2' => 'value2', /** very long list */]); than $io->definitonList(['title', 'title2', /* very long list*/], [[1, 2, , /* very long list*/]]); because you will be lost at some point. see this command for instance
I did that as the first implementation. But it does not work well. See the test suite to understand what I want to achieve :) |
What about $output->definitionList(
['foo' => 'bar'],
new TableSeparator(),
'this is a title',
new TableSeparator(),
['foo' => 'bar2']
); |
It's already supported and tested. Did I miss something? |
Yes, the variadic api :) i see several advantages;
|
Oh, indeed I miss-read your example :) |
it's still less than the current no. of brackets used symfony/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php Lines 64 to 90 in b2dadc1
Version keys btw)
in general i tend to avoid the mixed array structure. The 3rd advantage actually is it supports numeric/integer keys like any other, so less variance. |
@ro0NL Actually, It will be the exact same number of brackets :) |
0f6106c
to
09b244a
Compare
@ro0NL I finished this PR. I hope you like it :) |
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.
Nice :)
09b244a
to
8861fc9
Compare
08a1e18
to
a5b71b5
Compare
a5b71b5
to
1bf1af7
Compare
1bf1af7
to
66028fe
Compare
Thank you @lyrixx. |
…ntal table (lyrixx) This PR was merged into the 4.4 branch. Discussion ---------- [Console] Added support for definition list and horizontal table | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I need that in a projet where I want to display some data horizontally. Usage: ```php <?php use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Style\SymfonyStyle; require __DIR__.'/vendor/autoload.php'; $io = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput()); $io->table(['a', 'b', 'c'], [[1, 2, 3], [4, 5, 6]]); $io->table(['a', 'b', 'c'], [[1, 2, 3], [4, 5, 6]], true); $io->definitionList( ['foo' => 'bar'], new TableSeparator(), 'this is a title', new TableSeparator(), ['foo2' => 'bar2'] ); ```  Commits ------- 66028fe [Console] Added support for definition list
I need that in a projet where I want to display some data horizontally.
Usage: