]> BookStack Code Mirror - system-cli/blob - run.php
Added readme and some other meta files
[system-cli] / run.php
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 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;
17
18 // Setup our CLI
19 $app = new Application('bookstack-system');
20 $app->setCatchExceptions(false);
21
22 $app->add(new BackupCommand());
23 $app->add(new UpdateCommand());
24 $app->add(new InitCommand());
25 $app->add(new RestoreCommand());
26
27 try {
28     $app->run();
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());
34     exit(1);
35 }