diff --git a/dload.xml b/dload.xml index 280f686..fcc9972 100644 --- a/dload.xml +++ b/dload.xml @@ -1,3 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index a6e9f8b..61df208 100644 --- a/psalm.xml +++ b/psalm.xml @@ -15,7 +15,6 @@ - diff --git a/src/Command/Get.php b/src/Command/Get.php index 80aa91c..4e71613 100644 --- a/src/Command/Get.php +++ b/src/Command/Get.php @@ -32,6 +32,7 @@ public function configure(): void { $this->addArgument('binary', InputArgument::REQUIRED, 'Binary name, e.g. "rr", "dolt", "temporal" etc.'); $this->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to store the binary, e.g. "./bin"', "."); + $this->addOption('rename', null, InputOption::VALUE_OPTIONAL, 'Rename the binary, e.g. "rr"'); $this->addOption('arch', null, InputOption::VALUE_OPTIONAL, 'Architecture, e.g. "amd64", "arm64" etc.'); $this->addOption('os', null, InputOption::VALUE_OPTIONAL, 'Operating system, e.g. "linux", "darwin" etc.'); $this->addOption('stability', null, InputOption::VALUE_OPTIONAL, 'Stability, e.g. "stable", "beta" etc.'); @@ -76,10 +77,12 @@ protected function execute( )->finish(); $output->writeln('Architecture: ' . $container->get(Architecture::class)->name); - $output->writeln('Operating system: ' . $container->get(OperatingSystem::class)->name); - $output->writeln('Stability: ' . $container->get(Stability::class)->name); + $output->writeln('Op. system: ' . $container->get(OperatingSystem::class)->name); + $output->writeln('Stability: ' . $container->get(Stability::class)->name); + tr($container->get(\Internal\DLoad\Module\Common\Config\SoftwareRegistry::class)); + // $repo = 'roadrunner-server/roadrunner'; // trap( // GitHubRepository::fromDsn($repo)->getReleases()->first()->getAssets() diff --git a/src/Module/Common/Config/BuildInput.php b/src/Module/Common/Config/BuildInput.php index ab81865..e43aaa1 100644 --- a/src/Module/Common/Config/BuildInput.php +++ b/src/Module/Common/Config/BuildInput.php @@ -4,20 +4,34 @@ namespace Internal\DLoad\Module\Common\Config; +use Internal\DLoad\Module\Common\Architecture; use Internal\DLoad\Module\Common\Internal\Attribute\InputOption; +use Internal\DLoad\Module\Common\OperatingSystem; +use Internal\DLoad\Module\Common\Stability; /** * @internal - * @psalm-internal Internal\DLoad\Module\Common */ final class BuildInput { + /** + * Use {@see Architecture} to get final value. + */ #[InputOption('arch')] public ?string $arch = null; + /** + * Use {@see Stability} to get final value. + */ #[InputOption('stability')] public ?string $stability = null; + /** + * Use {@see OperatingSystem} to get final value. + */ #[InputOption('os')] public ?string $os = null; + + #[InputOption('version')] + public ?string $version = null; } diff --git a/src/Module/Common/Config/DestinationInput.php b/src/Module/Common/Config/DestinationInput.php new file mode 100644 index 0000000..b10d27d --- /dev/null +++ b/src/Module/Common/Config/DestinationInput.php @@ -0,0 +1,19 @@ + $this->getXPath($attribute), + $attribute instanceof XPathEmbedList => $this->getXPathEmbeddedList($attribute), $attribute instanceof Env => $this->env[$attribute->name] ?? null, $attribute instanceof InputOption => $this->inputOptions[$attribute->name] ?? null, $attribute instanceof InputArgument => $this->inputArguments[$attribute->name] ?? null, @@ -121,4 +123,30 @@ private function getXPath(XPath $attribute): mixed ? $value[$attribute->key] : null; } + + private function getXPathEmbeddedList(XPathEmbedList $attribute): array + { + $result = []; + $value = $this->xml?->xpath($attribute->path); + \is_array($value) or throw new \Exception(\sprintf('Invalid XPath `%s`', $attribute->path)); + + foreach ($value as $xml) { + \assert($xml instanceof \SimpleXMLElement); + + // Instantiate + $item = new $attribute->class(); + + $this->withXml($xml)->hydrate($item); + $result[] = $item; + } + + return $result; + } + + private function withXml(\SimpleXMLElement $xml): self + { + $self = clone $this; + $self->xml = $xml; + return $self; + } } diff --git a/src/Service/Factoriable.php b/src/Service/Factoriable.php index 82999eb..2b6075b 100644 --- a/src/Service/Factoriable.php +++ b/src/Service/Factoriable.php @@ -8,6 +8,7 @@ * Class creates new instances of itself. * * @method static create + * Method creates new instance of the class. May contain any injectable parameters. * * @internal */