c03e309aa9f535d248401141b6bc06d771afb867
[yaffs-website] / vendor / consolidation / site-alias / alias-tool
1 #!/usr/bin/env php
2 <?php
3
4 /**
5  * Example commandline front controller
6  *
7  * The commandline tool is useful for providing ad-hoc access to our class implementations
8  */
9
10 // If we're running from phar load the phar autoload file.
11 $pharPath = \Phar::running(true);
12 if ($pharPath) {
13     $autoloaderPath = "$pharPath/vendor/autoload.php";
14 } else {
15     if (file_exists(__DIR__.'/vendor/autoload.php')) {
16         $autoloaderPath = __DIR__.'/vendor/autoload.php';
17     } elseif (file_exists(__DIR__.'/../../autoload.php')) {
18         $autoloaderPath = __DIR__ . '/../../autoload.php';
19     } else {
20         die("Could not find autoloader. Run 'composer install'.");
21     }
22 }
23 $classLoader = require $autoloaderPath;
24
25 // Customization variables
26 $argv = $_SERVER['argv'];
27 $appName = "SiteAlias";
28 $appVersion = trim(file_get_contents(__DIR__ . '/VERSION'));
29 $commandClasses = [ \Consolidation\SiteAlias\Cli\SiteAliasCommands::class ];
30 $selfUpdateRepository = 'consolidation/site-alias';
31 $configPrefix = 'SITEALIAS';
32 $configFilePath = getenv($configPrefix . '_CONFIG') ?: getenv('HOME') . '/.site-alias/site-alias.yml';
33
34 // Define our Runner, and pass it the command classes we provide.
35 $runner = new \Robo\Runner($commandClasses);
36 $runner
37   ->setSelfUpdateRepository($selfUpdateRepository)
38   ->setConfigurationFilename($configFilePath)
39   ->setEnvConfigPrefix($configPrefix)
40   ->setClassLoader($classLoader);
41
42 // Execute the command and return the result.
43 $output = new \Symfony\Component\Console\Output\ConsoleOutput();
44 $statusCode = $runner->execute($argv, $appName, $appVersion, $output);
45 exit($statusCode);