Closed RyanNerd closed 2 years ago
Any chance this will get merged? We are running some cli commands in some cases in an HTTP context as it is super convenient.
Right now we have to make use of a separate logger to be able to forward output via HTTP, but being able to do something like this would be neat for our use case:
use \League\CLImate\CLImate;
use \League\CLImate\Util\Writer\WriterInterface;
class MyAction
{
public function handle(Request $request) : Response
{
// do something with the request
// create cli instance
$cli = new CLImate;
$cliLogger = new class implements WriterInterface {
public array $log = [];
public function write($content) {
$this->log[] = ['message' => $content, 'time' => microtime(true)];
}
};
$cli->output->add('logger', $cliLogger);
$cli->output->defaultTo('logger');
$registry = $this->container->get('command.registry');
$registry->execute('myapp:something', '-f -i 50 --another-option', $cli);
return new (Response())->json([
'something_log' => $cliLogger->log,
]);
}
}
Util/System/Linux::systemHasAnsiSupport()
throws an error in the cases where the constant STDOUT is undefined. FixedsystemHasAnsiSupport()
to return false in this instance.Closes: #172 See: https://stackoverflow.com/questions/17769041/notice-use-of-undefined-constant-stdout-assumed-stdout/28898174