4 if (php_sapi_name() !== 'cli') {
8 require __DIR__ . '/vendor/autoload.php';
10 use Cli\Commands\BackupCommand;
11 use Cli\Commands\InitCommand;
12 use Cli\Commands\RestoreCommand;
13 use Cli\Commands\UpdateCommand;
14 use Symfony\Component\Console\Application;
15 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
16 use Symfony\Component\Console\Output\ConsoleOutput;
19 $app = new Application('bookstack-system');
20 $app->setCatchExceptions(false);
22 $app->add(new BackupCommand());
23 $app->add(new UpdateCommand());
24 $app->add(new InitCommand());
25 $app->add(new RestoreCommand());
29 } catch (Exception $error) {
30 $output = (new ConsoleOutput())->getErrorOutput();
31 $output->getFormatter()->setStyle('error', new OutputFormatterStyle('red'));
32 $output->writeln("<error>\nAn error occurred when attempting to run a command:\n</error>");
33 $output->writeln($error->getMessage());