43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
|
<?php // "name":"Build stuff from stuff", "author":"Noccy"
|
||
|
|
||
|
namespace SparkPlug\Com\Noccy\Maker;
|
||
|
|
||
|
use Spark\Commands\Command;
|
||
|
use SparkPlug;
|
||
|
use Symfony\Component\Console\Input\InputInterface;
|
||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||
|
|
||
|
class MakerPlug extends SparkPlug
|
||
|
{
|
||
|
public function load()
|
||
|
{
|
||
|
$config = json_decode(file_get_contents(get_environment()->getConfigDirectory()."/maker.json"), true);
|
||
|
foreach ($config as $rule=>$info) {
|
||
|
if (str_starts_with($rule, '@')) {
|
||
|
$rule = substr($rule, 1);
|
||
|
register_command(new class($rule) extends Command {
|
||
|
private $rule;
|
||
|
public function __construct($rule)
|
||
|
{
|
||
|
$this->rule = $rule;
|
||
|
parent::__construct();
|
||
|
}
|
||
|
protected function configure()
|
||
|
{
|
||
|
$this->setName("make:{$this->rule}");
|
||
|
$this->setDescription("Run the {$this->rule} maker task");
|
||
|
}
|
||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (file_exists(get_environment()->getConfigDirectory()."/maker.json")) {
|
||
|
register_plugin("com.noccy.maker", new MakerPlug());
|
||
|
}
|