This repository has been archived on 2025-08-17. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
versa/src/Console/Command/AbstractCommand.php
Oliver Davies d289a01f3a Don't need to pass multiple arguments as a string
`./bin/console run -- --e prod --port 8001` now works without wrapping
multiple arbitrary arguments within a string.
2024-03-12 23:59:26 +00:00

58 lines
1.6 KiB
PHP

<?php
namespace App\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Filesystem\Filesystem;
abstract class AbstractCommand extends Command
{
public function __construct(
protected Filesystem $filesystem,
?string $name = null,
) {
parent::__construct(name: $name);
}
protected function configure(): void
{
// Allow for passing arbitrary arguments to the underlying command, for
// example, to run `composer install` with the `--no-dev` option:
//
// ./bin/console install -- --no-dev
//
// And to set the port and environment for a Sculpin project, multiple
// arguments can be passed at once:
//
// ./bin/console run -- -e prod --port 8001
$this->addArgument(
mode: InputArgument::IS_ARRAY,
name: '*',
);
$this->addOption(
name: 'language',
shortcut: 'l',
mode: InputArgument::OPTIONAL,
description: 'The project language',
suggestedValues: ['php', 'javascript'],
);
$this->addOption(
name: 'type',
shortcut: 't',
mode: InputArgument::OPTIONAL,
description: 'The project type',
suggestedValues: ['drupal', 'sculpin'],
);
$this->addOption(
name: 'working-dir',
shortcut: 'd',
mode: InputArgument::OPTIONAL,
description: 'The project\'s working directory',
default: '.',
);
}
}