-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi-client-resource-generator
More file actions
executable file
·55 lines (46 loc) · 1.5 KB
/
api-client-resource-generator
File metadata and controls
executable file
·55 lines (46 loc) · 1.5 KB
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
51
52
53
54
55
#!/usr/bin/env php
<?php declare(strict_types=1);
use ApiClients\Tools\ResourceGenerator\ResourceGenerator;
use function ApiClients\Tools\ResourceGenerator\readYaml;
use function ApiClients\Tools\ResourceGenerator\readYamlDir;
/**
* Locate and load autoloader
*/
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
if (file_exists($file)) {
require $file;
break;
}
}
/**
* Run application
*/
try {
if (!isset($argv[1])) {
throw new Exception('Missing configuration file');
}
if (!file_exists($argv[1])) {
throw new Exception('Passed configuration file doesn\'t exist');
}
/**
* Instance application
*/
$configuration = [];
$configuration += readYaml(__DIR__ . DIRECTORY_SEPARATOR . 'generator-settings.yml');
$configuration += readYaml($argv[1]);
$configuration['root'] = dirname($argv[1]) . DIRECTORY_SEPARATOR;
$configuration['files'] = readYamlDir($configuration['root'] . $configuration['yaml_location']);
(new ResourceGenerator($configuration))->run();
} catch (Exception $e) {
$message = $e->getMessage();
echo str_pad(' ', strlen($message)), PHP_EOL;
echo $message, PHP_EOL;
echo str_pad(' ', strlen($message)), PHP_EOL;
echo 'USAGE', PHP_EOL;
echo "\t" . 'api-client-resource-generator <configuration>', PHP_EOL;
echo PHP_EOL;
echo 'EXAMPLE', PHP_EOL;
echo "\t" . 'api-client-resource-generator ./resources.yaml', PHP_EOL;
exit(64);
}
exit(0);