diff --git a/src/Command/Get.php b/src/Command/Get.php index 7471c90..a165b35 100644 --- a/src/Command/Get.php +++ b/src/Command/Get.php @@ -138,8 +138,13 @@ private static function getDownloadActions(InputInterface $input, Actions $actio $toDownload[$action->software] = $action; } + $destinationPath = $input->getOption('path'); + return \array_map( - static fn(string $software): DownloadConfig => $toDownload[$software] ?? self::parseSoftware($software), + static fn(string $software): DownloadConfig => $toDownload[$software] ?? self::parseSoftware( + $software, + $destinationPath, + ), (array) $input->getArgument(self::ARG_SOFTWARE), ); } @@ -150,16 +155,18 @@ private static function getDownloadActions(InputInterface $input, Actions $actio * Supports "name:version" format to specify exact versions. * E.g. "rr:2.10.0", "dolt:1.2.3@beta", "temporal:1.3.1-priority", etc. * - * @param string $software Software identifier, e.g. "rr" or "dolt:1.2.3" + * @param non-empty-string $software Software identifier, e.g. "rr" or "dolt:1.2.3" + * @param non-empty-string|null $destinationPath Optional path to store the binary * @return DownloadConfig Parsed download configuration */ - private static function parseSoftware(string $software): DownloadConfig + private static function parseSoftware(string $software, ?string $destinationPath): DownloadConfig { [$name, $version] = \explode(':', $software, 2) + [1 => '']; $name === '' and throw new InvalidArgumentException("Software name cannot be empty, given: {$software}."); $action = DownloadConfig::fromSoftwareId($name); $version === '' or $action->version = $version; + $action->extractPath = $destinationPath; return $action; }