-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathso
executable file
·50 lines (43 loc) · 1.74 KB
/
so
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env php
<?php
use SoCli\CommandManager;
use SoCli\Command\PullCommands;
use Symfony\Component\Console\Application;
use Composer\InstalledVersions;
// The code related to autoloading was copied from https://github.com/drush-ops/drush/blob/13.x/drush.php.
// We use PWD if available because getcwd() resolves symlinks, which could take
// us outside of the Drupal root, making it impossible to find. In addition,
// is_dir() is used as the provided path may not be recognizable by PHP. For
// instance, Cygwin adds a '/cygdrive' prefix to the path which is a virtual
// directory.
$cwd = isset($_SERVER['PWD']) && is_dir($_SERVER['PWD']) ? $_SERVER['PWD'] : getcwd();
$autoloadFile = FALSE;
// Set up autoloader
$candidates = [
$_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php', // https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary
dirname(__DIR__, 2) . '/autoload.php',
__DIR__ . '/vendor/autoload.php', // For development of so itself.
];
foreach ($candidates as $candidate) {
if (file_exists($candidate)) {
$autoloadFile = $candidate;
break;
}
}
if (!$autoloadFile) {
throw new \Exception("Could not locate autoload.php. cwd is $cwd; __DIR__ is " . __DIR__);
}
$loader = include $autoloadFile;
if (!$loader) {
throw new \Exception("Invalid autoloadfile: $autoloadFile. cwd is $cwd; __DIR__ is " . __DIR__);
}
$application = new Application();
$application->setName('Shell Orchestration CLI');
$application->setVersion(InstalledVersions::getPrettyVersion('systemseed/so-cli'));
$application->addCommands([
new PullCommands(),
]);
$command_manager = new CommandManager();
$commands = $command_manager->getCommands();
$application->addCommands($commands);
$application->run();