forked from dagger/dagger-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodegenCommand.php
44 lines (36 loc) · 1.16 KB
/
CodegenCommand.php
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
<?php
namespace Dagger\Command;
use Dagger\Codegen\Codegen;
use Dagger\Codegen\SchemaGenerator;
use Dagger\Connection;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand('dagger:codegen')]
class CodegenCommand extends Command
{
private const WRITE_DIR =
__DIR__.DIRECTORY_SEPARATOR.
'..'.
DIRECTORY_SEPARATOR.
'..'.
DIRECTORY_SEPARATOR.
'generated';
private Connection $daggerConnection;
public function __construct()
{
parent::__construct();
$this->daggerConnection = Connection::get();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$client = $this->daggerConnection->connect();
$schema = (new SchemaGenerator($client))->getSchema();
$codegen = new Codegen($schema, self::WRITE_DIR, $io);
$codegen->generate();
return Command::SUCCESS;
}
}