Allow for arbitrary arguments

Remove the `--args` option and allow for arbitrary arguments.
This commit is contained in:
Oliver Davies 2024-03-12 21:25:56 +00:00
parent e499d42fa5
commit f94736183e
7 changed files with 21 additions and 13 deletions

View file

@ -2,9 +2,13 @@
## Unreleased ## 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) ## 0.3.0 (2024-02-25)

View file

@ -17,12 +17,16 @@ abstract class AbstractCommand extends Command
protected function configure(): void protected function configure(): void
{ {
$this->addOption( // Allow for passing arbitrary arguments to the underlying command, for
name: 'args', // example, to run `composer install` with the `--no-dev` option:
shortcut: 'a', //
mode: InputArgument::OPTIONAL, // ./bin/console install -- --no-dev
description: 'Any additonal arguments to pass to the command.', //
); // 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( $this->addOption(
name: 'language', name: 'language',

View file

@ -24,7 +24,7 @@ final class BuildCommand extends AbstractCommand
{ {
$projectType = null; $projectType = null;
$args = $input->getOption('args'); $args = $input->getArgument('*');
$workingDir = $input->getOption('working-dir'); $workingDir = $input->getOption('working-dir');
$language = $input->getOption('language') ?? (new DetermineProjectLanguage( $language = $input->getOption('language') ?? (new DetermineProjectLanguage(

View file

@ -21,7 +21,7 @@ final class InstallCommand extends AbstractCommand
{ {
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$args = $input->getOption('args'); $args = $input->getArgument('*');
$language = $input->getOption('language'); $language = $input->getOption('language');
$workingDir = $input->getOption('working-dir'); $workingDir = $input->getOption('working-dir');

View file

@ -31,7 +31,7 @@ final class PackageInstallCommand extends AbstractCommand
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$args = $input->getOption('args'); $args = $input->getArgument('*');
$workingDir = $input->getOption('working-dir'); $workingDir = $input->getOption('working-dir');
$language = $input->getOption('language') ?? (new DetermineProjectLanguage( $language = $input->getOption('language') ?? (new DetermineProjectLanguage(

View file

@ -22,7 +22,7 @@ final class RunCommand extends AbstractCommand
{ {
$projectType = null; $projectType = null;
$args = $input->getOption('args'); $args = $input->getArgument('*');
$workingDir = $input->getOption('working-dir'); $workingDir = $input->getOption('working-dir');
$filesystem = new Filesystem(); $filesystem = new Filesystem();

View file

@ -16,7 +16,7 @@ final class TestCommand extends AbstractCommand
{ {
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$args = $input->getOption('args'); $args = $input->getArgument('*');
$workingDir = $input->getOption('working-dir'); $workingDir = $input->getOption('working-dir');
// TODO: add support for node and jest. // TODO: add support for node and jest.