]> BookStack Code Mirror - system-cli/blob - scripts/run
Added central way to resolve app path, improved ouput formatting
[system-cli] / scripts / run
1 #!/usr/bin/env php
2 <?php
3
4 if (php_sapi_name() !== 'cli') {
5     exit;
6 }
7
8 require __DIR__ . '/vendor/autoload.php';
9
10 use Symfony\Component\Console\Application;
11 use Cli\Commands\BackupCommand;
12 use Cli\Commands\InitCommand;
13 use Cli\Commands\UpdateCommand;
14 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
15 use Symfony\Component\Console\Output\ConsoleOutput;
16
17 // Setup our CLI
18 $app = new Application('bookstack-system');
19 $app->setCatchExceptions(false);
20
21 $app->add(new BackupCommand());
22 $app->add(new UpdateCommand());
23 $app->add(new InitCommand());
24
25 try {
26     $app->run();
27 } catch (Exception $error) {
28     $output = (new ConsoleOutput())->getErrorOutput();
29     $output->getFormatter()->setStyle('error', new OutputFormatterStyle('red'));
30     $output->writeln("<error>\nAn error occurred when attempting to run a command:\n</error>");
31     $output->writeln($error->getMessage());
32     exit(1);
33 }