Rename --extra-args to --args

This commit is contained in:
Oliver Davies 2024-02-25 13:54:13 +00:00
parent 90e5e109e8
commit 5d32389606
7 changed files with 20 additions and 16 deletions

View file

@ -11,6 +11,10 @@
- Add `versa build` to build a Sculpin project.
- Add `--extra-args` to pass extra arguments to the underlying command.
### Changed
- Rename `--extra-args` to `--args`.
### Fixed
- Support multiple extra args with spaces, e.g. `versa test --testdox --filter foo`.

View file

@ -18,7 +18,7 @@ abstract class AbstractCommand extends Command
protected function configure(): void
{
$this->addOption(
name: 'extra-args',
name: 'args',
shortcut: 'a',
mode: InputArgument::OPTIONAL,
description: 'Any additonal arguments to pass to the command.',

View file

@ -18,7 +18,7 @@ final class BuildCommand extends AbstractCommand
{
$projectType = null;
$extraArgs = $input->getOption('extra-args');
$args = $input->getOption('args');
$workingDir = $input->getOption('working-dir');
$language = $input->getOption('language') ?? (new DetermineProjectLanguage(
@ -63,8 +63,8 @@ final class BuildCommand extends AbstractCommand
case ProjectType::Drupal->value:
if ($isDockerCompose) {
$process = Process::create(
args: explode(separator: ' ', string: strval($args)),
command: ['docker', 'compose', 'build'],
extraArgs: explode(separator: ' ', string: strval($extraArgs)),
workingDir: $workingDir,
);
@ -78,8 +78,8 @@ final class BuildCommand extends AbstractCommand
case ProjectType::Sculpin->value:
$process = Process::create(
args: explode(separator: ' ', string: strval($args)),
command: ['./vendor/bin/sculpin', 'generate'],
extraArgs: explode(separator: ' ', string: strval($extraArgs)),
workingDir: $workingDir,
);
@ -91,8 +91,8 @@ final class BuildCommand extends AbstractCommand
switch ($projectType) {
case ProjectType::Fractal->value:
$process = Process::create(
args: explode(separator: ' ', string: strval($args)),
command: ['npx', 'fractal', 'build'],
extraArgs: explode(separator: ' ', string: strval($extraArgs)),
workingDir: $workingDir,
);

View file

@ -14,7 +14,7 @@ final class InstallCommand extends AbstractCommand
{
public function execute(InputInterface $input, OutputInterface $output): int
{
$extraArgs = $input->getOption('extra-args');
$args = $input->getOption('args');
$workingDir = $input->getOption('working-dir');
$language = $input->getOption('language') ?? (new DetermineProjectLanguage(
@ -26,12 +26,12 @@ final class InstallCommand extends AbstractCommand
// TODO: Composer in Docker Compose?
$process = Process::create(
args: explode(separator: ' ', string: strval($args)),
command: $this->getCommand(
filesystem: $filesystem,
language: $language,
workingDir: $workingDir,
),
extraArgs: explode(separator: ' ', string: strval($extraArgs)),
workingDir: $workingDir,
);

View file

@ -17,7 +17,7 @@ final class RunCommand extends AbstractCommand
{
$projectType = null;
$extraArgs = $input->getOption('extra-args');
$args = $input->getOption('args');
$workingDir = $input->getOption('working-dir');
$filesystem = new Filesystem();
@ -60,8 +60,8 @@ final class RunCommand extends AbstractCommand
if ($isDockerCompose) {
$process = Process::create(
args: $args,
command: ['docker', 'compose', 'up'],
extraArgs: $extraArgs,
workingDir: $workingDir,
);
@ -71,8 +71,8 @@ final class RunCommand extends AbstractCommand
switch ($projectType) {
case ProjectType::Fractal->value:
$process = Process::create(
args: $args,
command: ['npx', 'fractal', 'start', '--sync'],
extraArgs: $extraArgs,
workingDir: $workingDir,
);
@ -82,8 +82,8 @@ final class RunCommand extends AbstractCommand
case ProjectType::Sculpin->value:
$process = Process::create(
args: $args,
command: ['./vendor/bin/sculpin', 'generate', '--server', '--watch'],
extraArgs: $extraArgs,
workingDir: $workingDir,
);

View file

@ -11,7 +11,7 @@ final class TestCommand extends AbstractCommand
{
public function execute(InputInterface $input, OutputInterface $output): int
{
$extraArgs = $input->getOption('extra-args');
$args = $input->getOption('args');
$workingDir = $input->getOption('working-dir');
// TODO: add support for node and jest.
@ -33,8 +33,8 @@ final class TestCommand extends AbstractCommand
// TODO: commands in Docker Compose?
$process = Process::create(
args: explode(separator: ' ', string: $args),
command: $command,
extraArgs: explode(separator: ' ', string: $extraArgs),
workingDir: $workingDir,
);

View file

@ -14,11 +14,11 @@ final class Process
/**
* @param non-empty-array<int, non-empty-string> $command
* @param string $workingDir
* @param string[] $extraArgs
* @param string[] $args
*/
public static function create(array $command, string $workingDir, array $extraArgs = []): SymfonyProcess
public static function create(array $command, string $workingDir, array $args = []): SymfonyProcess
{
$process = new SymfonyProcess(command: array_filter([...$command, ...$extraArgs]));
$process = new SymfonyProcess(command: array_filter([...$command, ...$args]));
$process->setTty(true);
$process->setWorkingDirectory($workingDir);