4 if (php_sapi_name() !== 'cli') {
8 require __DIR__ . '/vendor/autoload.php';
10 use Symfony\Component\Console\Application;
11 use Cli\Commands\BackupCommand;
12 use Cli\Commands\InitCommand;
13 use Cli\Commands\UpdateCommand;
15 // Get the directory of the CLI "entrypoint", adjusted to be the real
16 // location where running via a phar.
18 if (str_starts_with($scriptDir, 'phar://')) {
19 $scriptDir = dirname(Phar::running(false));
21 // TODO - Add smarter strategy for locating install
22 // (working directory or directory of running script or maybe passed option?)
23 $bsDir = dirname($scriptDir);
26 $app = new Application('bookstack-system');
28 $app->add(new BackupCommand($bsDir));
29 $app->add(new UpdateCommand($bsDir));
30 $app->add(new InitCommand());
34 } catch (Exception $error) {
35 fwrite(STDERR, "An error occurred when attempting to run a command:\n");
36 fwrite(STDERR, $error->getMessage() . "\n");