Misc fixes and improvements

* Added request logging to com.noccy.apiclient
* Added plugin com.noccy.watcher
* Added pipe command and filter support
* Fixes and stubs
This commit is contained in:
2021-12-14 23:01:25 +01:00
parent 8cc1eac7a4
commit 30dfd4889b
22 changed files with 648 additions and 3 deletions

View File

@ -0,0 +1,53 @@
<?php // "name":"Watch files and act when they are changed", "author":"Noccy"
namespace SparkPlug\Com\Noccy\Watcher;
class Rule
{
private array $filenames = [];
private array $actions = [];
private bool $initialTrigger = false;
private string $name;
public function __construct()
{
$this->name = "unnamed rule";
}
public static function createFromConfig(array $config)
{
$rule = new Rule();
$rule->filenames = (array)$config['watch'];
$rule->initialTrigger = ((bool)$config['initial-trigger'])??false;
$rule->actions = $config['actions']??[];
$rule->name = $config['name']??$rule->name;
return $rule;
}
public function getName(): string
{
return $this->name;
}
public function getInitialTrigger(): bool
{
return $this->initialTrigger;
}
public function getWatchedFiles(): array
{
return $this->filenames;
}
public function getActions(): array
{
return $this->actions;
}
}