Skip to content

Commit b36d34a

Browse files
committed
Speed-up console commands by lazy loading them
1 parent 147055d commit b36d34a

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

bin/objectstorage

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use Symfony\Component\Console\Application;
5-
64
require_once(__DIR__ . "/../vendor/autoload.php");
75

6+
use ObjectStorage\Command\DecryptCommand;
7+
use ObjectStorage\Command\DeleteCommand;
8+
use ObjectStorage\Command\DownloadCommand;
9+
use ObjectStorage\Command\EncryptCommand;
10+
use ObjectStorage\Command\GenerateKeyCommand;
11+
use ObjectStorage\Command\ListCommand;
12+
use ObjectStorage\Command\UploadCommand;
13+
use Symfony\Component\Console\Application;
14+
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
15+
816
$application = new Application('ObjectStorage CLI utility', '1.0.0');
917
$application->setCatchExceptions(true);
10-
$application->add(new \ObjectStorage\Command\UploadCommand());
11-
$application->add(new \ObjectStorage\Command\DownloadCommand());
12-
$application->add(new \ObjectStorage\Command\ListCommand());
13-
$application->add(new \ObjectStorage\Command\DeleteCommand());
14-
$application->add(new \ObjectStorage\Command\GenerateKeyCommand());
15-
$application->add(new \ObjectStorage\Command\EncryptCommand());
16-
$application->add(new \ObjectStorage\Command\DecryptCommand());
18+
$application->setCommandLoader(new FactoryCommandLoader([
19+
'objectstorage:upload' => function () { return new UploadCommand(); },
20+
'objectstorage:download' => function () { return new DownloadCommand(); },
21+
'objectstorage:list' => function () { return new ListCommand(); },
22+
'objectstorage:delete' => function () { return new DeleteCommand(); },
23+
'objectstorage:generatekey' => function () { return new GenerateKeyCommand(); },
24+
'objectstorage:encrypt' => function () { return new EncryptCommand(); },
25+
'objectstorage:decrypt' => function () { return new DecryptCommand(); },
26+
]));
1727
$application->run();

0 commit comments

Comments
 (0)