-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphizz
More file actions
executable file
·101 lines (92 loc) · 3.7 KB
/
phizz
File metadata and controls
executable file
·101 lines (92 loc) · 3.7 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use NunoMaduro\Collision\Provider as Collision;
use Phizz\Generator\Generators\PhizzGenerator;
use Phizz\Generator\Objects\Configuration;
use Phizz\Generator\Parsers\FileParser;
use Phizz\Generator\Parsers\SchemaParser;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
// create a new symfony console application
$application = new Application();
// register nunomaduro/collision
(new Collision)->register();
$application->add(new Command("generate"))
->addOption(
name: "schema",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI schema file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/openapi-3.0.0.json"
)
->addOption(
name: "routes",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI routes table file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/routesTable.json"
)
->addOption(
name: "seasons",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI seasons file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/enums/seasons.json"
)
->addOption(
name: "queues",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI queues file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/enums/queues.json"
)
->addOption(
name: "maps",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI maps file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/enums/maps.json"
)
->addOption(
name: "game-modes",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI game modes file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/enums/gameModes.json"
)
->addOption(
name: "game-types",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI game types file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/enums/gameTypes.json"
)
->addOption(
name: "queue-types",
mode: InputOption::VALUE_REQUIRED,
description: "RiotAPI queue types file path/url",
default: "https://www.mingweisamuel.com/riotapi-schema/enums/queueTypes.json"
)
->setCode(function (InputInterface $input, OutputInterface $output): int {
// create the parsers
$fp = new FileParser(console: $output);
$sp = new SchemaParser(console: $output);
// create the generator
$generator = new PhizzGenerator(
config: new Configuration(
console: $output,
schema: $sp->parse(file: $input->getOption("schema")),
routes: $fp->parse(file: $input->getOption("routes")),
enums: [
'season' => $fp->parse(file: $input->getOption("seasons")),
'queue' => $fp->parse(file: $input->getOption("queues")),
'map' => $fp->parse(file: $input->getOption("maps")),
'gameMode' => $fp->parse(file: $input->getOption("game-modes")),
'gameType' => $fp->parse(file: $input->getOption("game-types")),
'queueType' => $fp->parse(file: $input->getOption("queue-types")),
]
)
);
// generate the code
$generator->generate();
return Command::SUCCESS;
});
/** @noinspection PhpUnhandledExceptionInspection */
$application->run();