From f94736183e067b806afe82ef5e24ab1d4d13b0e5 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 12 Mar 2024 21:25:56 +0000 Subject: [PATCH] Allow for arbitrary arguments Remove the `--args` option and allow for arbitrary arguments. --- CHANGELOG.md | 8 ++++++-- src/Console/Command/AbstractCommand.php | 16 ++++++++++------ src/Console/Command/BuildCommand.php | 2 +- src/Console/Command/InstallCommand.php | 2 +- src/Console/Command/PackageInstallCommand.php | 2 +- src/Console/Command/RunCommand.php | 2 +- src/Console/Command/TestCommand.php | 2 +- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2309bc2..309ad42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,13 @@ ## Unreleased -### Fixed +N/A. -- Fix `args` in `run` command. +## 0.4.0 (2024-03-12) + +### Changed + +- Remove the `args` command and allow for arbitrary arguments - e.g. `./bin/console install -- --no-dev` to run `composer install` with the `--no-dev` option. ## 0.3.0 (2024-02-25) diff --git a/src/Console/Command/AbstractCommand.php b/src/Console/Command/AbstractCommand.php index 576bfd9..6fe223b 100644 --- a/src/Console/Command/AbstractCommand.php +++ b/src/Console/Command/AbstractCommand.php @@ -17,12 +17,16 @@ abstract class AbstractCommand extends Command protected function configure(): void { - $this->addOption( - name: 'args', - shortcut: 'a', - mode: InputArgument::OPTIONAL, - description: 'Any additonal arguments to pass to the command.', - ); + // 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 as a string: + // + // ./bin/console run -- '-e prod --port 8001' + $this->addArgument('*'); $this->addOption( name: 'language', diff --git a/src/Console/Command/BuildCommand.php b/src/Console/Command/BuildCommand.php index 0748461..ec58697 100644 --- a/src/Console/Command/BuildCommand.php +++ b/src/Console/Command/BuildCommand.php @@ -24,7 +24,7 @@ final class BuildCommand extends AbstractCommand { $projectType = null; - $args = $input->getOption('args'); + $args = $input->getArgument('*'); $workingDir = $input->getOption('working-dir'); $language = $input->getOption('language') ?? (new DetermineProjectLanguage( diff --git a/src/Console/Command/InstallCommand.php b/src/Console/Command/InstallCommand.php index 7645e32..5166efd 100644 --- a/src/Console/Command/InstallCommand.php +++ b/src/Console/Command/InstallCommand.php @@ -21,7 +21,7 @@ final class InstallCommand extends AbstractCommand { public function execute(InputInterface $input, OutputInterface $output): int { - $args = $input->getOption('args'); + $args = $input->getArgument('*'); $language = $input->getOption('language'); $workingDir = $input->getOption('working-dir'); diff --git a/src/Console/Command/PackageInstallCommand.php b/src/Console/Command/PackageInstallCommand.php index 860f534..9773376 100644 --- a/src/Console/Command/PackageInstallCommand.php +++ b/src/Console/Command/PackageInstallCommand.php @@ -31,7 +31,7 @@ final class PackageInstallCommand extends AbstractCommand public function execute(InputInterface $input, OutputInterface $output): int { - $args = $input->getOption('args'); + $args = $input->getArgument('*'); $workingDir = $input->getOption('working-dir'); $language = $input->getOption('language') ?? (new DetermineProjectLanguage( diff --git a/src/Console/Command/RunCommand.php b/src/Console/Command/RunCommand.php index 882074c..dde764f 100644 --- a/src/Console/Command/RunCommand.php +++ b/src/Console/Command/RunCommand.php @@ -22,7 +22,7 @@ final class RunCommand extends AbstractCommand { $projectType = null; - $args = $input->getOption('args'); + $args = $input->getArgument('*'); $workingDir = $input->getOption('working-dir'); $filesystem = new Filesystem(); diff --git a/src/Console/Command/TestCommand.php b/src/Console/Command/TestCommand.php index dde362a..8598044 100644 --- a/src/Console/Command/TestCommand.php +++ b/src/Console/Command/TestCommand.php @@ -16,7 +16,7 @@ final class TestCommand extends AbstractCommand { public function execute(InputInterface $input, OutputInterface $output): int { - $args = $input->getOption('args'); + $args = $input->getArgument('*'); $workingDir = $input->getOption('working-dir'); // TODO: add support for node and jest.