]> BookStack Code Mirror - system-cli/blob - scripts/run
Outlined a general working backup approach
[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 Cli\Commands\BackupCommand;
11 use Minicli\App;
12
13 // Get the directory of the CLI "entrypoint", adjusted to be the real
14 // location where running via a phar.
15 $scriptDir = __DIR__;
16 if (str_starts_with($scriptDir, 'phar://')) {
17     $scriptDir = dirname(Phar::running(false));
18 }
19 $bsDir = dirname($scriptDir);
20
21 // Load in our .env file from the parent directory
22 $dotenv = Dotenv\Dotenv::createImmutable($bsDir);
23 $dotenv->safeLoad();
24
25 // Setup our CLI
26 $app = new App();
27 $app->setSignature('./run');
28
29 $app->registerCommand('backup', [new BackupCommand($bsDir), 'handle']);
30
31 $app->runCommand($argv);