-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e1c118
commit bd02200
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SonsOfPHP\Bard\Console\Command; | ||
|
||
use SonsOfPHP\Bard\JsonFile; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use SonsOfPHP\Component\Json\Json; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* @author Joshua Estes <joshua@sonsofphp.com> | ||
*/ | ||
final class CopyCommand extends AbstractCommand | ||
{ | ||
protected static $defaultName = 'copy'; | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->setDescription('Copies a file to each package') | ||
->addArgument('source', InputArgument::REQUIRED, 'Source file to copy') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
$sourceFile = $input->getOption('working-dir') . '/' . $input->getArgument('source'); | ||
if (!is_file($sourceFile)) { | ||
throw new \RuntimeException(sprintf('The file "%s" is an invalid file.', $sourceFile)); | ||
} | ||
$bardJsonFile = new JsonFile($input->getOption('working-dir') . '/bard.json'); | ||
foreach ($bardJsonFile->getSection('packages') as $pkg) { | ||
$process = new Process(['cp', $sourceFile, $pkg['path']]); | ||
$io->text($process->getCommandLine()); | ||
$this->getHelper('process')->run($output, $process); | ||
Check failure on line 41 in src/SonsOfPHP/Bard/src/Console/Command/CopyCommand.php GitHub Actions / Psalm (8.1)UndefinedInterfaceMethod
|
||
} | ||
|
||
$io->success('File has been copied.'); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |