Skip to content

Commit

Permalink
Allow --dl to be relative to _SCRIPTDIR_
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Dec 3, 2019
1 parent a9424c2 commit 3305781
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docs/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ first line accordingly:
echo "Hello world\n";
```

The `--dl` can be relative. By default, it's relative to the CWD (which is
more intuitive for direct invocations), but you may make it relative to the
script with the constant `_SCRIPTDIR_`.

```bash
#!/usr/bin/env pogo --dl='_SCRIPTDIR_/.my-script.deps'
<?php
echo "Hello world\n";
```

Or if you wanted to lock deps into a read-only mode for multiuser systems:

```php
Expand Down
8 changes: 5 additions & 3 deletions src/Command/DownloadCommandTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Pogo\Command;

use Pogo\PathUtil;
use Pogo\PogoProject;
use Symfony\Component\Console\Input\InputInterface;

Expand Down Expand Up @@ -48,9 +49,10 @@ public function initProject(InputInterface $input, $target) {
* @return string
*/
public function pickBaseDir(InputInterface $input, $scriptMetadata) {
$result = $input->getOption('dl');
if ($result) {
return $result;
$dl = $input->getOption('dl');
if ($dl) {
$dl = preg_replace('/^_SCRIPTDIR_/', dirname($scriptMetadata->file), $dl);
return PathUtil::evaluateDots(PathUtil::makeAbsolute($dl));
}

// Pick a base and calculate a hint/digested name.
Expand Down
1 change: 1 addition & 0 deletions src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$output->writeln("<comment>Action-Options:</comment>");
$output->writeln(" <info>-f</info> Force; recreate project, even if it appears current");
$output->writeln(" <info>--dl=DIR</info> Output dependencies in this directory");
$output->writeln(" Use constant _SCRIPTDIR_ to start relative to the target script.");
$output->writeln("");
$output->writeln("<comment>Environment:</comment>");
$output->writeln(" <info>POGO_BASE</info> Default location for output folders");
Expand Down

0 comments on commit 3305781

Please sign in to comment.