Page MenuHomePhabricator

D10704.id25700.diff
No OneTemporary

D10704.id25700.diff

diff --git a/src/lint/linter/ArcanistScriptAndRegexLinter.php b/src/lint/linter/ArcanistScriptAndRegexLinter.php
--- a/src/lint/linter/ArcanistScriptAndRegexLinter.php
+++ b/src/lint/linter/ArcanistScriptAndRegexLinter.php
@@ -155,6 +155,8 @@
*/
final class ArcanistScriptAndRegexLinter extends ArcanistLinter {
+ private $script = null;
+ private $regex = null;
private $output = array();
public function getInfoName() {
@@ -285,6 +287,34 @@
return 'script-and-regex';
}
+ public function getLinterConfigurationOptions() {
+ // These fields are optional only to avoid breaking things.
+ $options = array(
+ 'script' => array(
+ 'type' => 'optional string',
+ 'help' => pht('Script to execute.'),
+ ),
+ 'regex' => array(
+ 'type' => 'optional regex',
+ 'help' => pht('The regex to process output with.'),
+ ),
+ );
+
+ return $options + parent::getLinterConfigurationOptions();
+ }
+
+ public function setLinterConfigurationValue($key, $value) {
+ switch ($key) {
+ case 'script':
+ $this->script = $value;
+ return;
+ case 'regex':
+ $this->regex = $value;
+ return;
+ }
+
+ return parent::setLinterConfigurationValue($key, $value);
+ }
/* -( Parsing Output )----------------------------------------------------- */
@@ -353,15 +383,17 @@
* @task config
*/
private function getConfiguredScript() {
+ if (strlen($this->script)) {
+ return $this->script;
+ }
+
$key = 'linter.scriptandregex.script';
$config = $this->getEngine()
->getConfigurationManager()
->getConfigFromAnySource($key);
if (!$config) {
- throw new ArcanistUsageException(
- "ArcanistScriptAndRegexLinter: ".
- "You must configure '{$key}' to point to a script to execute.");
+ throw new ArcanistUsageException('Parameter missing: script');
}
// NOTE: No additional validation since the "script" can be some random
@@ -379,15 +411,16 @@
* @task config
*/
private function getConfiguredRegex() {
+ if (strlen($this->regex))
+ return $this->regex;
+
$key = 'linter.scriptandregex.regex';
$config = $this->getEngine()
->getConfigurationManager()
->getConfigFromAnySource($key);
if (!$config) {
- throw new ArcanistUsageException(
- "ArcanistScriptAndRegexLinter: ".
- "You must configure '{$key}' with a valid PHP PCRE regex.");
+ throw new ArcanistUsageException('Parameter missing: regex');
}
// NOTE: preg_match() returns 0 for no matches and false for compile error;

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 11, 12:17 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7483506
Default Alt Text
D10704.id25700.diff (2 KB)

Event Timeline