-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.php
More file actions
executable file
·55 lines (45 loc) · 1.4 KB
/
generate.php
File metadata and controls
executable file
·55 lines (45 loc) · 1.4 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
/**
* @author Magebit <info@magebit.com>
* @copyright Copyright (c) Magebit, Ltd. (https://magebit.com)
* @license MIT
*/
declare(strict_types=1);
// Load Composer autoloader
require_once __DIR__ . '/vendor/autoload.php';
use Magebit\UcpSpecGenerator\Generator;
// Define directories
$specDir = __DIR__ . '/spec';
$outputDir = __DIR__ . '/generated';
// Parse command line arguments
$options = getopt('', ['clean', 'help']);
if (isset($options['help'])) {
echo "UCP Spec Generator\n";
echo "==================\n\n";
echo "Usage: php generate.php [options]\n\n";
echo "Options:\n";
echo " --clean Clean output directory before generation\n";
echo " --help Show this help message\n\n";
echo "Description:\n";
echo " Generates PHP interfaces from JSON Schema files in the spec/ directory.\n";
echo " Output is saved to the generated/ directory.\n\n";
exit(0);
}
try {
// Create generator instance
$generator = new Generator($specDir, $outputDir);
// Clean output directory if requested
if (isset($options['clean'])) {
$generator->cleanOutputDirectory();
}
// Generate interfaces
$generator->generate();
echo "\n✓ Success!\n";
exit(0);
} catch (\Exception $e) {
echo "\n✗ Error: " . $e->getMessage() . "\n";
echo "\nStack trace:\n";
echo $e->getTraceAsString() . "\n";
exit(1);
}