Skip to content

[Console] OutputFormatterStyle for html colors #11392

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

Closed
rvanlaak opened this issue Jul 15, 2014 · 6 comments
Closed

[Console] OutputFormatterStyle for html colors #11392

rvanlaak opened this issue Jul 15, 2014 · 6 comments

Comments

@rvanlaak
Copy link
Contributor

Currently the OutputFormatter of the Console command nicely colors the output when used on cli.

Some of the command I've created are executed via a backend setup module, the output is returned to the controller using a StreamOutput

    $application = new Application($this->get('kernel'));
    $application->setAutoExit(false);

    $fp = tmpfile();
    $output = new StreamOutput($fp, StreamOutput::VERBOSITY_NORMAL, <new HtmlFormatter()>);

    $application->run(new ArrayInput($options), $output);

Feature: a new OutputFormatterStyle to format the output according with html colors / bold / etc

This could be part of the DX-initiative (?)

@stof
Copy link
Member

stof commented Jul 15, 2014

this would be quite complex to write, because this would require escaping any other HTML, which will be a huge pain.
It is probably much easier to use https://github.com/sensiolabs/ansi-to-html to convert the ANSI colors to HTML (which is what SensioLabs Insight uses AFAIK)

@fabpot
Copy link
Member

fabpot commented Jul 15, 2014

see sensiolabs/ansi-to-html

@rvanlaak
Copy link
Contributor Author

This is great! Would be a nice addition for the documentation of the Console component.

@stof
Copy link
Member

stof commented Jul 15, 2014

i think this could be described in a cookbook. You should open an issue on the symfony-docs repo suggesting it (or even better contribute to the doc with such a cookbook).

anyway, closing this issue as @fabpot agrees with me that the converter is a better way to handle it.

@stof stof closed this as completed Jul 15, 2014
@rvanlaak
Copy link
Contributor Author

Adding it to the Cookbook is fine, will do that when I've got some spare time at the end of this week.

@weaverryan
Copy link
Member

An addition to the docs is a great idea! I didn't know about the sensiolabs library - I have a use for this in a project :).

weaverryan added a commit to symfony/symfony-docs that referenced this issue May 23, 2015
…Rvanlaak)

This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #5062).

Discussion
----------

Cookbook about Command in Application with AnsiToHtml

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | >= 2.3
| Fixed tickets | symfony/symfony#11392

Commits
-------

0799366 Documentation about using Command in Controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants