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:
53
plugins/com.noccy.watcher/Rule.php
Normal file
53
plugins/com.noccy.watcher/Rule.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user