#!/usr/bin/env php getFormatter(); $formatter->setStyle('warn', new OutputFormatterStyle('yellow')); $formatter->setStyle('info', new OutputFormatterStyle('cyan')); $formatter->setStyle('success', new OutputFormatterStyle('green')); $formatter->setStyle('error', new OutputFormatterStyle('red')); // Run the command and handle errors try { $output->writeln("WARNING: This CLI is in alpha testing."); $output->writeln("There's a high chance of issues, and the CLI API is subject to change."); $output->writeln(""); $app->run(null, $output); } catch (CommandError $error) { $output = (new ConsoleOutput())->getErrorOutput(); $output->getFormatter()->setStyle('error', new OutputFormatterStyle('red')); $output->writeln('' . $error->getMessage() . ''); exit(1); } catch (Exception $error) { $output = (new ConsoleOutput())->getErrorOutput(); $output->getFormatter()->setStyle('error', new OutputFormatterStyle('red')); $output->writeln("\nAn error occurred when attempting to run a command:\n"); $output->writeln($error->getMessage()); exit(1); }