Skip to content

Commit

Permalink
Make generator a single-command app
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Oct 2, 2023
1 parent ace7f60 commit 6728f0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To run the generator, you need to have PHP 8.2+ installed and Composer.

1. Move to the `generator` directory: `cd generator`
1. Install dependencies: `composer install`
1. Run the generator: `bin/console generate`
1. Run the generator: `./generate`

## Configuration

Expand Down
5 changes: 3 additions & 2 deletions generator/bin/console → generator/generate
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
exit(1);
}

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';

$application = new Application();
$application->add(new GenerateCommand(__DIR__ . '/../../', __DIR__ . '/../config'));
$application->add(new GenerateCommand(__DIR__ . '/../', __DIR__ . '/config'));
$application->setDefaultCommand('generate');
$application->run();
9 changes: 7 additions & 2 deletions generator/src/Command/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use MongoDB\CodeGenerator\ExpressionClassGenerator;
use MongoDB\CodeGenerator\ExpressionFactoryGenerator;
use MongoDB\CodeGenerator\OperatorGenerator;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,7 +20,6 @@
use function is_array;
use function sprintf;

#[AsCommand(name: 'generate', description: 'Generate code for mongodb/mongodb library')]
final class GenerateCommand extends Command
{
public function __construct(
Expand All @@ -31,6 +29,13 @@ public function __construct(
parent::__construct();
}

public function configure(): void
{
$this->setName('generate');
$this->setDescription('Generate code for mongodb/mongodb library');
$this->setHelp('Generate code for mongodb/mongodb library');
}

public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Generating code for mongodb/mongodb library');
Expand Down

0 comments on commit 6728f0a

Please sign in to comment.