Page MenuHomePhabricator

D10706.id25702.diff
No OneTemporary

D10706.id25702.diff

diff --git a/src/workflow/ArcanistLintersWorkflow.php b/src/workflow/ArcanistLintersWorkflow.php
--- a/src/workflow/ArcanistLintersWorkflow.php
+++ b/src/workflow/ArcanistLintersWorkflow.php
@@ -11,7 +11,7 @@
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
- **linters** [__options__]
+ **linters** [__options__] [__search__ ...]
EOTEXT
);
}
@@ -21,6 +21,10 @@
Supports: cli
List the available and configured linters, with information about
what they do and which versions are installed.
+
+ If __search__ words are provided, only linters that match the search
+ will be printed. Search is case-insensitive, and performed against
+ name and configuration name of each linter.
EOTEXT
));
}
@@ -30,6 +34,7 @@
'verbose' => array(
'help' => pht('Show detailed information, including options.'),
),
+ '*' => 'search',
);
}
@@ -96,6 +101,10 @@
'error' => 'red',
);
+ $linter_info = $this->filterByNames(
+ $linter_info,
+ $this->getArgument('search'));
+
foreach ($linter_info as $key => $linter) {
$status = $linter['status'];
$color = $color_map[$status];
@@ -212,4 +221,19 @@
return $text_map;
}
+ private function filterByNames($linters, $search_terms) {
+ if (!$search_terms) {
+ return $linters;
+ }
+ $filtered = array();
+ $terms = '/'.implode('|', $search_terms).'/i';
+
+ foreach ($linters as $key => $linter) {
+ if (preg_match($terms, $linter['name']) ||
+ preg_match($terms, $linter['short'])) {
+ $filtered[$key] = $linter;
+ }
+ }
+ return $filtered;
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 29, 8:23 PM (3 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706374
Default Alt Text
D10706.id25702.diff (1 KB)

Event Timeline