Task #49016

TYPO3 Flow Base Distribution - Task #51183: CLI improvements

Use Symfony.Console for Output + Interaction in CommandController

Added by Marc Neuhaus about 8 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-06-11
Due date:
% Done:

100%

Estimated time:
Sprint:
PHP Version:
Has patch:
No
Complexity:

Description

I think we should make use of the Smfony.Console component for output and interaction. It offers anything someone writing a command might wish for:

- easy output coloring through "<error>Warning!</error>"
- TableHelper to render a formatted table
- ProgressHelper to render and advance and progress bar
- DialogHelper with numerous types of questions like: select, ask, confirm, askHidden, etc

I already tested to use it inside an ActionController yesterday, which worked quite easily.

Another thing i testet yesterday was, to ask the user for missing arguments instead of failing with "Required argument "foo" is not set.":

./flow kickstart:model              
Please specify the required argument "packageKey": My.Package
Please specify the required argument "modelName": 

This change would add a dependency for Symfony/Console, but in most cases it is there already because Doctrine depends on it.

#2

Updated by Bastian Waidelich almost 8 years ago

  • Parent task set to #51183
#3

Updated by Kay Strobach over 7 years ago

@Marc please post your example code, i'm extremly interested.

#4

Updated by Kay Strobach over 7 years ago

That's what i found out so far:

https://gist.github.com/kaystrobach/7500128

The cleaner version would be to modify the CliResponse directly, this would also make it possible to use the progressbar and the table renderer ...
This should be possible with AOP as well -.-

#5

Updated by Kay Strobach over 7 years ago

btw it does not make any sense for me to buffer the output of a cli request, it should be always passed directly.
the send method should be simply empty and the appendContent should directly print the content!

#6

Updated by Kay Strobach over 7 years ago

Just updated my gist with an AOP implementation https://gist.github.com/kaystrobach/7500128

#7

Updated by Marc Neuhaus over 7 years ago

Hey i converted My test into an abstract Controller in Famelo.Common:

https://github.com/mneuhaus/Famelo.Common/blob/master/Documentation/AbstractInteractiveCommandController.md

:-)

#8

Updated by Kay Strobach over 7 years ago

could you make a RFC for that as patch - i would gladly review

#9

Updated by Marc Neuhaus over 7 years ago

i don't think this will have a chance to get into master in this current form, because it completely circumvents the default TYPO3.Flow Response.

Not sure how exactly to tackle this. i'll have to talk to robert about this i guess :)

#10

Updated by Kay Strobach over 7 years ago

there was a chat with atleast RafealK today about this problem, i will take a look on it, i think we need to implement this in CLI\Response.

#11

Updated by Stefano Kowalke about 7 years ago

Is there any updates on that topic?

#13

Updated by Gerrit Code Review about 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/30653

#14

Updated by Marc Neuhaus about 7 years ago

Conclusion of the technical discussion meeting (http://wiki.typo3.org/TYPO3_Neos-DiscussionMeetings):

As we already have a hard dependency to Symfony/Console we decided to extend the existing \TYPO3\Flow\Cli\CommandController to use the Symfony console internally. The API will be backwards compatible with one exception: $this->output() and $this->outputLine() will no longer buffer the output until the end of the request but render content directly to the console. This is a desired side-effect that enables features like progress bars.

#15

Updated by Gerrit Code Review about 7 years ago

Patch set 2 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/30653

#16

Updated by Gerrit Code Review about 7 years ago

Patch set 3 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/30653

#17

Updated by Gerrit Code Review about 7 years ago

Patch set 4 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/30653

#18

Updated by Anonymous about 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF