]> BookStack Code Mirror - system-cli/blobdiff - scripts/run
Added update command
[system-cli] / scripts / run
index ff38c81515318bfdee8a5f5e7d63221f57ba07eb..ca3ea5644a9d7276d2ce4a496e7aab0df547d4fe 100644 (file)
@@ -7,9 +7,10 @@ if (php_sapi_name() !== 'cli') {
 
 require __DIR__ . '/vendor/autoload.php';
 
+use Symfony\Component\Console\Application;
 use Cli\Commands\BackupCommand;
-use Cli\Commands\CommandError;
-use Minicli\App;
+use Cli\Commands\InitCommand;
+use Cli\Commands\UpdateCommand;
 
 // Get the directory of the CLI "entrypoint", adjusted to be the real
 // location where running via a phar.
@@ -17,21 +18,20 @@ $scriptDir = __DIR__;
 if (str_starts_with($scriptDir, 'phar://')) {
     $scriptDir = dirname(Phar::running(false));
 }
+// TODO - Add smarter strategy for locating install
+//   (working directory or directory of running script or maybe passed option?)
 $bsDir = dirname($scriptDir);
 
-// Load in our .env file from the parent directory
-$dotenv = Dotenv\Dotenv::createImmutable($bsDir);
-$dotenv->safeLoad();
-
 // Setup our CLI
-$app = new App();
-$app->setSignature('./run');
+$app = new Application('bookstack-system');
 
-$app->registerCommand('backup', [new BackupCommand($bsDir), 'handle']);
+$app->add(new BackupCommand($bsDir));
+$app->add(new UpdateCommand($bsDir));
+$app->add(new InitCommand());
 
 try {
-    $app->runCommand($argv);
-} catch (CommandError $error) {
+    $app->run();
+} catch (Exception $error) {
     fwrite(STDERR, "An error occurred when attempting to run a command:\n");
     fwrite(STDERR, $error->getMessage() . "\n");
     exit(1);