From e81e0cef7186d6fa55d562ded4d1c2914783484c Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 19 Feb 2024 12:30:02 +0000 Subject: [PATCH] Add --working-dir --- CHANGELOG.md | 1 + versa | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69eaa9..7baf022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unrelased +- Add `--working-dir` to run versa in a different directory. - Add `-t` as a shortcut for `--type`. ## 0.1.0 diff --git a/versa b/versa index 9adb748..67552b6 100755 --- a/versa +++ b/versa @@ -24,6 +24,14 @@ $application->addOption( suggestedValues: ['drupal', 'sculpin'], ); +$application->addOption( + name: 'working-dir', + shortcut: 'd', + mode: InputArgument::OPTIONAL, + description: 'The project\'s working directory', + default: '.', +); + $application->setCode(function (InputInterface $input): int { // TODO: only allow defined commands - build, install, test, run. switch ($input->getArgument('command')) { @@ -31,6 +39,7 @@ $application->setCode(function (InputInterface $input): int { // TODO: Composer in Docker Compose? $process = new Process(command: ['composer', 'install']); $process->setTty(true); + $process->setWorkingDirectory($input->getOption('working-dir')); $process->run(); break; @@ -40,6 +49,7 @@ $application->setCode(function (InputInterface $input): int { // TODO: how to pass arbitrary arguments, such as `--port 8001`? $process = new Process(command: ['./vendor/bin/sculpin', 'generate', '--server', '--watch']); $process->setTty(true); + $process->setWorkingDirectory($input->getOption('working-dir')); $process->run(); break; } @@ -50,6 +60,7 @@ $application->setCode(function (InputInterface $input): int { // TODO: commands in Docker Compose? $process = new Process(command: ['./vendor/bin/phpunit']); $process->setTty(true); + $process->setWorkingDirectory($input->getOption('working-dir')); $process->run(); break; }