Tasker/bin/tasker
Funky Waddle 3ac2894fd8
Some checks are pending
CI / tasker (8.2) (push) Waiting to run
CI / tasker (8.3) (push) Waiting to run
feat: complete Tasker project implementation, documentation, and examples
2026-02-22 01:14:22 -06:00

46 lines
1 KiB
PHP
Executable file

#!/usr/bin/env php
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use Phred\Tasker\Runner;
use Phred\Tasker\ArgvParser;
use Phred\TaskerBridges\Phred\InputAdapter;
use Phred\TaskerBridges\Phred\OutputAdapter;
$runner = new Runner();
// $runner->discover();
$parser = new ArgvParser($argv);
$commandName = $parser->getCommandName() ?: 'list';
$command = $runner->find($commandName);
$output = new OutputAdapter(!$parser->isNoAnsi());
$output->setVerbosity($parser->getVerbosity());
if (!$command) {
$output->error(sprintf('Command "%s" not found.', $commandName));
exit(1);
}
// Map remaining arguments to command arguments
$cmdArgs = $command->getArguments();
$remaining = $parser->getRemainingArguments();
$mappedArgs = [];
$i = 0;
foreach ($cmdArgs as $name => $desc) {
if (isset($remaining[$i])) {
$mappedArgs[$name] = $remaining[$i];
}
$i++;
}
$input = new InputAdapter($mappedArgs, []);
$exitCode = $runner->run($command, $input, $output);
exit($exitCode);