]> BookStack Code Mirror - system-cli/blob - scripts/run
Added update command
[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
15 // Get the directory of the CLI "entrypoint", adjusted to be the real
16 // location where running via a phar.
17 $scriptDir = __DIR__;
18 if (str_starts_with($scriptDir, 'phar://')) {
19     $scriptDir = dirname(Phar::running(false));
20 }
21 // TODO - Add smarter strategy for locating install
22 //   (working directory or directory of running script or maybe passed option?)
23 $bsDir = dirname($scriptDir);
24
25 // Setup our CLI
26 $app = new Application('bookstack-system');
27
28 $app->add(new BackupCommand($bsDir));
29 $app->add(new UpdateCommand($bsDir));
30 $app->add(new InitCommand());
31
32 try {
33     $app->run();
34 } catch (Exception $error) {
35     fwrite(STDERR, "An error occurred when attempting to run a command:\n");
36     fwrite(STDERR, $error->getMessage() . "\n");
37     exit(1);
38 }