nerdexam
Adobe

AD0-E716 · Question #6

An Adobe Commerce developer is creating a new console command to perform a complex task with a lot of potential terminal output. If an error occurs, they want to provide a message that has higher…

The correct answer is A. Call the setDecorationType(Stype) method On the Symfony\Console\Output\OutputInterface. The developer can customize the appearance of the error message by calling the setDecorationType() method on the Symfony\Console\Output\OutputInterface object before calling writeln(). The setDecorationType() method takes a single argument, which is the type of decoration that…

Customization

Question

An Adobe Commerce developer is creating a new console command to perform a complex task with a lot of potential terminal output. If an error occurs, they want to provide a message that has higher visibility than some of the other content that may be appearing, so they want to ensure it is highlighted in red (as seen in the screenshot):

How can they customize the appearance of this message?

Options

  • ACall the setDecorationType(Stype) method On the Symfony\Console\Output\OutputInterface
  • BWrap the output content in tags like <error>, <info>, or <comment>.
  • CThrow a new commandException with the desired message passed as an argument.

How the community answered

(33 responses)
  • A
    88% (29)
  • B
    3% (1)
  • C
    9% (3)

Explanation

The developer can customize the appearance of the error message by calling the setDecorationType() method on the Symfony\Console\Output\OutputInterface object before calling writeln(). The setDecorationType() method takes a single argument, which is the type of decoration that the developer wants to use. In this case, the developer wants to use the STYPE_ERROR decoration, which will highlight the message in red. Here is an example of how to customize the appearance of the error message: $output = new Symfony\Console\Output\ConsoleOutput(); $output->setDecorationType(Symfony\Console\Output\OutputInterface::STYPE_ERROR); $output->writeln('This is an error message.'); The output of this code will be an error message that is highlighted in red.

Topics

#console command#Symfony Console#output formatting#CLI

Community Discussion

No community discussion yet for this question.

Full AD0-E716 Practice