Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15348162
D10706.id27085.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D10706.id27085.diff
View Options
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 any search
+ word 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',
);
}
@@ -46,46 +51,7 @@
$built = array();
}
- // Note that an engine can emit multiple linters of the same class to run
- // different rulesets on different groups of files, so these linters do not
- // necessarily have unique classes or types.
- $groups = array();
- foreach ($built as $linter) {
- $groups[get_class($linter)][] = $linter;
- }
-
- $linter_info = array();
- foreach ($linters as $key => $linter) {
- $installed = idx($groups, $key, array());
- $exception = null;
-
- if ($installed) {
- $status = 'configured';
- try {
- $version = head($installed)->getVersion();
- } catch (Exception $ex) {
- $status = 'error';
- $exception = $ex;
- }
- } else {
- $status = 'available';
- $version = null;
- }
-
- $linter_info[$key] = array(
- 'short' => $linter->getLinterConfigurationName(),
- 'class' => get_class($linter),
- 'status' => $status,
- 'version' => $version,
- 'name' => $linter->getInfoName(),
- 'uri' => $linter->getInfoURI(),
- 'description' => $linter->getInfoDescription(),
- 'exception' => $exception,
- 'options' => $linter->getLinterConfigurationOptions(),
- );
- }
-
- $linter_info = isort($linter_info, 'short');
+ $linter_info = $this->getLintersInfo($linters, $built);
$status_map = $this->getStatusMap();
$pad = ' ';
@@ -96,6 +62,11 @@
'error' => 'red',
);
+ $search_terms = $this->getArgument('search');
+ if ($search_terms) {
+ $linter_info = $this->filterByNames($linter_info, $search_terms);
+ }
+
foreach ($linter_info as $key => $linter) {
$status = $linter['status'];
$color = $color_map[$status];
@@ -212,4 +183,63 @@
return $text_map;
}
+ private function getLintersInfo(array $linters, array $built) {
+ // Note that an engine can emit multiple linters of the same class to run
+ // different rulesets on different groups of files, so these linters do not
+ // necessarily have unique classes or types.
+ $groups = array();
+ foreach ($built as $linter) {
+ $groups[get_class($linter)][] = $linter;
+ }
+
+ $linter_info = array();
+ foreach ($linters as $key => $linter) {
+ $installed = idx($groups, $key, array());
+ $exception = null;
+
+ if ($installed) {
+ $status = 'configured';
+ try {
+ $version = head($installed)->getVersion();
+ } catch (Exception $ex) {
+ $status = 'error';
+ $exception = $ex;
+ }
+ } else {
+ $status = 'available';
+ $version = null;
+ }
+
+ $linter_info[$key] = array(
+ 'short' => $linter->getLinterConfigurationName(),
+ 'class' => get_class($linter),
+ 'status' => $status,
+ 'version' => $version,
+ 'name' => $linter->getInfoName(),
+ 'uri' => $linter->getInfoURI(),
+ 'description' => $linter->getInfoDescription(),
+ 'exception' => $exception,
+ 'options' => $linter->getLinterConfigurationOptions(),
+ );
+ }
+
+ return isort($linter_info, 'short');
+ }
+
+ private function filterByNames(array $linters, array $search_terms) {
+ $filtered = array();
+
+ foreach ($linters as $key => $linter) {
+ $name = $linter['name'];
+ $short = $linter['short'];
+ foreach ($search_terms as $term) {
+ if (stripos($name, $term) !== false ||
+ stripos($short, $term) !== false) {
+ $filtered[$key] = $linter;
+ }
+ }
+ }
+ return $filtered;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 11, 2:20 PM (12 h, 57 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7530507
Default Alt Text
D10706.id27085.diff (4 KB)
Attached To
Mode
D10706: arc linters: Filter by name, make display one-line
Attached
Detach File
Event Timeline
Log In to Comment