diff --git a/CHANGELOG.md b/CHANGELOG.md index 63ddf33..6ce17e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/src/Console/Command/AbstractCommand.php b/src/Console/Command/AbstractCommand.php index 15e0e4f..576bfd9 100644 --- a/src/Console/Command/AbstractCommand.php +++ b/src/Console/Command/AbstractCommand.php @@ -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.', diff --git a/src/Console/Command/BuildCommand.php b/src/Console/Command/BuildCommand.php index fc92923..a051fb6 100644 --- a/src/Console/Command/BuildCommand.php +++ b/src/Console/Command/BuildCommand.php @@ -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, ); diff --git a/src/Console/Command/InstallCommand.php b/src/Console/Command/InstallCommand.php index 7270c39..8f721ab 100644 --- a/src/Console/Command/InstallCommand.php +++ b/src/Console/Command/InstallCommand.php @@ -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, ); diff --git a/src/Console/Command/RunCommand.php b/src/Console/Command/RunCommand.php index c957a97..e32a60d 100644 --- a/src/Console/Command/RunCommand.php +++ b/src/Console/Command/RunCommand.php @@ -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, ); diff --git a/src/Console/Command/TestCommand.php b/src/Console/Command/TestCommand.php index a498c2d..03db04a 100644 --- a/src/Console/Command/TestCommand.php +++ b/src/Console/Command/TestCommand.php @@ -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, ); diff --git a/src/Process/Process.php b/src/Process/Process.php index e4b1867..c1d6497 100644 --- a/src/Process/Process.php +++ b/src/Process/Process.php @@ -14,11 +14,11 @@ final class Process /** * @param non-empty-array $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);