Skip to content

Commit

Permalink
Merge pull request #5 from thunderer/generator-autoloader-path
Browse files Browse the repository at this point in the history
Generator autoloader path
  • Loading branch information
thunderer authored Sep 30, 2019
2 parents 96e76d6 + 54f4f6e commit b4a4454
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions bin/generate
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ namespace X;

use Thunder\Platenum\Command\GenerateCommand;

$vendorLoaderPath = dirname(__DIR__, 3).'/vendor/autoload.php';
$vendorLoaderPath = dirname(__DIR__, 4).'/vendor/autoload.php';
$packageLoaderPath = dirname(__DIR__, 1).'/vendor/autoload.php';
$loader = require file_exists($vendorLoaderPath) ? $vendorLoaderPath : $packageLoaderPath;

if(file_exists($vendorLoaderPath)) {
$loader = require $vendorLoaderPath;
} elseif(file_exists($packageLoaderPath)) {
$loader = require $packageLoaderPath;
} else {
echo 'There is no autoloader present. Did you run composer install?'."\n";
exit(1);
}

(new GenerateCommand($loader))->execute($argc, $argv);
6 changes: 4 additions & 2 deletions src/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public function execute(int $argc, array $argv): void
$this->writeln('');

if($argc < 4) {
$this->writeln('usage: bin/generate source class keys,values');
$this->writeln(' bin/generate constants MyEnum key1,key2=value2,key3');
$this->writeln('usage: bin/generate <source> <class> MEMBER=value,MEMBER=value,...');
$this->writeln('examples: bin/generate constants UserStatus ACTIVE=1,INACTIVE=2');
$this->writeln(' bin/generate docblock PaymentType INTERNAL,EXTERNAL');
$this->writeln(' bin/generate static "Project\\Namespace\\Currency" PLN=10,EUR=12,USD=14');
exit(1);
}
if(false === in_array($argv[1], ['constants', 'docblock', 'static'], true)) {
Expand Down

0 comments on commit b4a4454

Please sign in to comment.