QuestionQ2

Developing with Admin

An Adobe Commerce developer is building a new console command to perform a complex task that can generate a great deal of terminal output. If an error happens, they want to display a message with greater visibility than other content that may be shown, ensuring it is highlighted in red (as shown in the screenshot):

How can they customize this message's appearance?

Question Image

  • A Call the setDecorationType($type) method on the Symfony\Console\Output\OutputInterface object before calling writeln().
  • B Wrap the output content in tags like <error>, <info>, or <comment>.
  • C Throw a new CommandException with the desired message passed as an argument.
Explanation

Symfony Console supports built-in output-formatting tags. Wrapping the message in the <error> tag renders it as white text on a red background, making the error prominent among other terminal output.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!