-
Notifications
You must be signed in to change notification settings - Fork 11.3k
[5.1][Console][WIP] Laravel Console Style #8338
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
private $progressBar; | ||
private $lineLength; | ||
|
||
/** |
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.
oops :)
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.
Yeah copied from Symfony, but this is WIP so please comment on CS after it's finished.
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.
Fixed all that, removed a lot too ;)
Looking pretty nice so far. :) |
But should we move to 'Symfony style' questions and error/success blocks, or keep the current style (1 line errors, answers directly after questions) |
Not sure. Could you show us a comparison please? |
I quite like the symfony questions. Ping @taylorotwell. |
I've tweaked the code a bit and fixed the CS, so I guess this is ready for review. |
The todo list is incomplete? |
@@ -29,7 +29,7 @@ class Command extends \Symfony\Component\Console\Command\Command { | |||
/** | |||
* The output interface implementation. | |||
* | |||
* @var \Symfony\Component\Console\Output\OutputInterface | |||
* @var LaravelStyle |
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.
Please use the FQCN in here.
protected function borderedBlock($messages, $style = null, $borderChar = '*', $paddingSize = 3) | ||
{ | ||
$messages = (array) $messages; | ||
$lines = array(); |
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.
please use short array syntax on new code
Regarding the todo list: Deciding the layout is up to you guys, I just made the example with proposed layout. So if you're okay with that, I'll check it off. About the tables, I can't use the style layout as it doesn't have a |
private $lineLength; | ||
|
||
/** | ||
* Create a new LaravelStyle instance. |
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.
Create a new Laravel style instance.
please
I think default is ok. I'll ask Taylor... |
I added the |
Current output is a lot more compact then Symfony, which adds more new lines and spacing in front of lines. But I'll leave that up to Taylor to decide. Below the output from the example from the Symfony issue, so you can see the difference:
|
Personally I would rather just use whatever Symfony ships with as it is less for us to maintain going forward. |
So shall I submit a PR to use the Symfony styles as the default output and use that to simplify the questions etc? |
Sure, we can. Is that a lot of code? Whatever is the least custom code for On Thu, Apr 23, 2015 at 1:29 PM, Barry vd. Heuvel notifications@github.com
|
That would be pretty much the same changes to the Command class as in this PR, but then using the Symfony style class instead of a new Laravel Style class. |
So what if we just don't change anything. The console component has no On Thu, Apr 23, 2015 at 2:07 PM, Barry vd. Heuvel notifications@github.com
|
What do you mean? The SymfonyStyle adds styling for commonly used things, similar to our current helper methods (see table in opening post). So we can use that to make our questions prettier and reduce logic. |
The styling in this original PR adds the same (very basic) styling to the interface, using the same style as the current styling. It pretty basic, except perhaps the orderBlock method. |
Submitted a simplified PR in #8537 |
In Symfony 2.7, Style Guide helpers are added (see symfony/symfony#14057 and symfony/symfony@96b4210 )
This adds a StyleInterface with a few common helpers, similar to the helpers that Laravel currently adds.
Perhaps it would be a good idea to make a Laravel Style, that perhaps extends the Symfony one. The existing helper functions could be redirected to the Style ouput, new methods can also be directed to the style helper or be available as $style for example.
The OutputStyle also implements the OutputInterface, so the Output could be changed to the OutputStyle.
Pros:
Cons:
Example:
Table with current/symfony helpers:
As this is for 5.1 (because only in Symfony 2.7), we could change the signatures perhaps, if it's worth the BC break. Otherwise keep the existing method signatures and make the style available for new helpers.
This PR is a Work in Progress. It replaces #8306
This shows how it could work, but it should be decided which style we want to follow. The old Laravel style is a bit more 'compact' then Symfony, which has more newlines etc and more verbose errors/notes. See symfony/symfony#14057 for screenshots.
Todo