Skip to content

Commit 4574db0

Browse files
author
Jamie Hannaford
committed
add bin
1 parent 1de5578 commit 4574db0

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Scraper
2+
3+
This is a scraper for automatically generating `Api.php` and `Params.php` files for the Rackspace provider.
4+
5+
It is run like so:
6+
7+
```bash
8+
./bin/generate ~/projects/rst-files ~/projects/rackspace/src/LoadBalancer/v1 Rackspace\\LoadBalancer\\v1
9+
```

bin/generate

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
function includeIfExists($file) {
5+
if (file_exists($file)) {
6+
return include $file;
7+
}
8+
}
9+
10+
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
11+
fwrite(STDERR,
12+
'You must set up the project dependencies, run the following commands:'.PHP_EOL.
13+
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
14+
'php composer.phar install'.PHP_EOL
15+
);
16+
exit(1);
17+
}
18+
19+
foreach (['inputDir', 'outputDir', 'namespace'] as $key => $name) {
20+
if (!isset($argv[$key+1])) {
21+
fwrite(STDERR,
22+
sprintf("ERROR: You did not provide `%s'. Correct usage is ./bin/generate <inputDir> <outputDir> <namespace>\n",
23+
$name
24+
));
25+
exit(1);
26+
}
27+
}
28+
29+
$finder = new \Scraper\Finder($argv[1], $argv[2], $argv[3]);
30+
$finder->execute();

0 commit comments

Comments
 (0)