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;
14 // Get the directory of the CLI "entrypoint", adjusted to be the real
15 // location where running via a phar.
17 if (str_starts_with($scriptDir, 'phar://')) {
18 $scriptDir = dirname(Phar::running(false));
20 $bsDir = dirname($scriptDir);
23 $app = new Application('bookstack-system');
25 $app->add(new BackupCommand($bsDir));
26 $app->add(new InitCommand());
30 } catch (Exception $error) {
31 fwrite(STDERR, "An error occurred when attempting to run a command:\n");
32 fwrite(STDERR, $error->getMessage() . "\n");