Skip to content

Commit 1ed9b50

Browse files
authored
fix: Process --path flag in the get command (#70)
1 parent da8e36d commit 1ed9b50

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Command/Get.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,13 @@ private static function getDownloadActions(InputInterface $input, Actions $actio
138138
$toDownload[$action->software] = $action;
139139
}
140140

141+
$destinationPath = $input->getOption('path');
142+
141143
return \array_map(
142-
static fn(string $software): DownloadConfig => $toDownload[$software] ?? self::parseSoftware($software),
144+
static fn(string $software): DownloadConfig => $toDownload[$software] ?? self::parseSoftware(
145+
$software,
146+
$destinationPath,
147+
),
143148
(array) $input->getArgument(self::ARG_SOFTWARE),
144149
);
145150
}
@@ -150,16 +155,18 @@ private static function getDownloadActions(InputInterface $input, Actions $actio
150155
* Supports "name:version" format to specify exact versions.
151156
* E.g. "rr:2.10.0", "dolt:1.2.3@beta", "temporal:1.3.1-priority", etc.
152157
*
153-
* @param string $software Software identifier, e.g. "rr" or "dolt:1.2.3"
158+
* @param non-empty-string $software Software identifier, e.g. "rr" or "dolt:1.2.3"
159+
* @param non-empty-string|null $destinationPath Optional path to store the binary
154160
* @return DownloadConfig Parsed download configuration
155161
*/
156-
private static function parseSoftware(string $software): DownloadConfig
162+
private static function parseSoftware(string $software, ?string $destinationPath): DownloadConfig
157163
{
158164
[$name, $version] = \explode(':', $software, 2) + [1 => ''];
159165
$name === '' and throw new InvalidArgumentException("Software name cannot be empty, given: {$software}.");
160166

161167
$action = DownloadConfig::fromSoftwareId($name);
162168
$version === '' or $action->version = $version;
169+
$action->extractPath = $destinationPath;
163170

164171
return $action;
165172
}

0 commit comments

Comments
 (0)