Skip to content

Commit

Permalink
Merge pull request #7 from WyriHaximus/replace-climate-with-something…
Browse files Browse the repository at this point in the history
…-that-can-handle-asterixes-in-paths

Replace climate with something that can handle asterixes in paths
  • Loading branch information
WyriHaximus committed Jun 19, 2016
2 parents 5dd154e + 9d11f3f commit 7e45023
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 167 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -34,6 +34,12 @@ For example:
./vendor/bin/api-client-resource-generator ./yaml/project.yaml ./src/Resource
```

Generate multiple resources at once:

```
./vendor/bin/api-client-resource-generator ./yaml/*.yaml ./src/Resource
```

# License

The MIT License (MIT)
Expand Down
34 changes: 25 additions & 9 deletions api-client-resource-generator
@@ -1,7 +1,8 @@
#!/usr/bin/env php
<?php

use League\CLImate\CLImate;
use Aura\Cli\CliFactory;
use Aura\Cli\Status;
use WyriHaximus\ApiClient\Tools\ResourceGenerator;

/**
Expand All @@ -17,20 +18,35 @@ foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/vendor/autoload.php'
/**
* Instance application
*/
$climate = new CLImate();
$resourceGenerator = new ResourceGenerator($climate);
$cliFactory = new CliFactory();
$cliContext = $cliFactory->newContext($GLOBALS);
$cliStdio = $cliFactory->newStdio();
$resourceGenerator = new ResourceGenerator($cliContext, $cliStdio);

/**
* Run application
*/
try {
@$climate->arguments->parse();
$resourceGenerator->run();
} catch (Exception $e) {
$message = $e->getMessage();
$climate->backgroundRed(str_pad(' ', strlen($message)));
$climate->backgroundRed($message);
$climate->backgroundRed(str_pad(' ', strlen($message)));
$climate->br();
$climate->usage();
$cliStdio->errln(str_pad(' ', strlen($message)));
$cliStdio->errln($message);
$cliStdio->errln(str_pad(' ', strlen($message)));

$cliStdio->outln('USAGE');
$cliStdio->outln("\t" . 'api-client-resource-generator <definition1> [<definition1>] <path>');
$cliStdio->outln('');
$cliStdio->outln('SINGLE EXAMPLE');
$cliStdio->outln("\t" . 'api-client-resource-generator ./yaml/resource.yaml ./src/Resource/');
$cliStdio->outln('');
$cliStdio->outln('MULTI EXAMPLE');
$cliStdio->outln("\t" . 'api-client-resource-generator ./yaml/resource-a.yaml ./yaml/resource-b.yaml ./src/Resource/');
$cliStdio->outln('');
$cliStdio->outln('WILDCARD EXAMPLE');
$cliStdio->outln("\t" . 'api-client-resource-generator ./yaml/*.yaml ./src/Resource/');

exit(Status::USAGE);
}

exit(Status::SUCCESS);
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -9,12 +9,12 @@
],
"require": {
"php": "^7.0",
"league/climate": "^3.2",
"nikic/php-parser": "^2.1",
"symfony/yaml": "^2.8||^3.0",
"doctrine/inflector": "^1.1",
"wyrihaximus/api-client": "dev-master",
"friendsofphp/php-cs-fixer": "^1.11"
"friendsofphp/php-cs-fixer": "^1.11",
"aura/cli": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "^5.2.3",
Expand Down
163 changes: 62 additions & 101 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e45023

Please sign in to comment.