From: epriestley Date: Mon, 12 May 2014 03:23:07 +0000 (-0700) Subject: Provide `arc linters --verbose` to list all available options X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=54c377448db8dbc40f0ca86d43c837d30e493485;p=arcanist.git Provide `arc linters --verbose` to list all available options Summary: Ref T2039. I'll update the corresponding documentation. It feels a little awkward that this is disconnected from `getLinterConfigurationOptions()`, but I dislike returning weird ad-hoc structures more than I dislike having two methods. Most linters don't implement either of these anyway. Test Plan: Ran `arc linters` and `arc linters --verbose`. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T2039 Differential Revision: https://secure.phabricator.com/D9062 --- diff --git a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php index b3cb0db3..330e7397 100644 --- a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php +++ b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php @@ -47,6 +47,16 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { $linter = clone $linters[$type]; $linter->setEngine($this); $more = $linter->getLinterConfigurationOptions(); + + foreach ($more as $key => $option_spec) { + PhutilTypeSpec::checkMap( + $option_spec, + array( + 'type' => 'string', + 'help' => 'string', + )); + $more[$key] = $option_spec['type']; + } } else { // We'll raise an error below about the invalid "type" key. $linter = null; diff --git a/src/lint/linter/ArcanistCSharpLinter.php b/src/lint/linter/ArcanistCSharpLinter.php index 0d6f3c22..b0b7b244 100644 --- a/src/lint/linter/ArcanistCSharpLinter.php +++ b/src/lint/linter/ArcanistCSharpLinter.php @@ -2,8 +2,6 @@ /** * C# linter for Arcanist. - * - * @group linter */ final class ArcanistCSharpLinter extends ArcanistLinter { @@ -27,8 +25,19 @@ final class ArcanistCSharpLinter extends ArcanistLinter { public function getLinterConfigurationOptions() { $options = parent::getLinterConfigurationOptions(); - $options["discovery"] = 'map>'; - $options["binary"] = 'string'; + $options['discovery'] = array( + 'type' => 'map>', + 'help' => pht('Provide a discovery map.'), + ); + + + // TODO: This should probably be replaced with "bin" when this moves + // to extend ExternalLinter. + + $options['binary'] = array( + 'type' => 'string', + 'help' => pht('Override default binary.'), + ); return $options; } diff --git a/src/lint/linter/ArcanistExternalLinter.php b/src/lint/linter/ArcanistExternalLinter.php index d05fa219..a1ea0b72 100644 --- a/src/lint/linter/ArcanistExternalLinter.php +++ b/src/lint/linter/ArcanistExternalLinter.php @@ -442,15 +442,33 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter { } } - public function getLinterConfigurationOptions() { $options = array( - 'bin' => 'optional string | list', - 'flags' => 'optional list', + 'bin' => array( + 'type' => 'optional string | list', + 'help' => pht( + 'Specify a string (or list of strings) identifying the binary '. + 'which should be invoked to execute this linter. This overrides '. + 'the default binary. If you provide a list of possible binaries, '. + 'the first one which exists will be used.') + ), + 'flags' => array( + 'type' => 'optional list', + 'help' => pht( + 'Provide a list of additional flags to pass to the linter on the '. + 'command line.'), + ), ); if ($this->shouldUseInterpreter()) { - $options['interpreter'] = 'optional string | list'; + $options['interpreter'] = array( + 'type' => 'optional string | list', + 'help' => pht( + 'Specify a string (or list of strings) identifying the interpreter '. + 'which should be used to invoke the linter binary. If you provide '. + 'a list of possible interpreters, the first one that exists '. + 'will be used.'), + ); } return $options + parent::getLinterConfigurationOptions(); diff --git a/src/lint/linter/ArcanistLesscLinter.php b/src/lint/linter/ArcanistLesscLinter.php index 1315e371..c267389e 100644 --- a/src/lint/linter/ArcanistLesscLinter.php +++ b/src/lint/linter/ArcanistLesscLinter.php @@ -40,8 +40,17 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter { public function getLinterConfigurationOptions() { return parent::getLinterConfigurationOptions() + array( - 'lessc.strict-math' => 'optional bool', - 'lessc.strict-units' => 'optional bool', + 'lessc.strict-math' => array( + 'type' => 'optional bool', + 'help' => pht( + 'Enable strict math, which only processes mathematical expressions '. + 'inside extraneous parentheses.'), + ), + 'lessc.strict-units' => array( + 'type' => 'optional bool', + 'help' => pht( + 'Enable strict handling of units in expressions.'), + ), ); } diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php index ae40eb90..90d3b46b 100644 --- a/src/lint/linter/ArcanistLinter.php +++ b/src/lint/linter/ArcanistLinter.php @@ -74,6 +74,7 @@ abstract class ArcanistLinter { get_class($this)); } + public function getLinterPriority() { return 1.0; } @@ -360,8 +361,18 @@ abstract class ArcanistLinter { } return array( - 'severity' => 'optional map', - 'severity.rules' => 'optional map', + 'severity' => array( + 'type' => 'optional map', + 'help' => pht( + 'Provide a map from lint codes to adjusted severity levels: error, '. + 'warning, advice, autofix or disabled.') + ), + 'severity.rules' => array( + 'type' => 'optional map', + 'help' => pht( + 'Provide a map of regular expressions to severity levels. All '. + 'matching codes have their severity adjusted.'), + ), ); } diff --git a/src/lint/linter/ArcanistTextLinter.php b/src/lint/linter/ArcanistTextLinter.php index 1599a750..115f5bd5 100644 --- a/src/lint/linter/ArcanistTextLinter.php +++ b/src/lint/linter/ArcanistTextLinter.php @@ -33,7 +33,12 @@ final class ArcanistTextLinter extends ArcanistLinter { public function getLinterConfigurationOptions() { $options = array( - 'text.max-line-length' => 'optional int', + 'text.max-line-length' => array( + 'type' => 'optional int', + 'help' => pht( + 'Adjust the maximum line length before a warning is raised. By '. + 'default, a warning is raised on lines exceeding 80 characters.'), + ), ); return $options + parent::getLinterConfigurationOptions(); diff --git a/src/workflow/ArcanistLintersWorkflow.php b/src/workflow/ArcanistLintersWorkflow.php index d96488c3..a2dc604c 100644 --- a/src/workflow/ArcanistLintersWorkflow.php +++ b/src/workflow/ArcanistLintersWorkflow.php @@ -26,7 +26,11 @@ EOTEXT } public function getArguments() { - return array(); + return array( + 'verbose' => array( + 'help' => pht('Show detailed information, including options.'), + ), + ); } public function run() { @@ -77,6 +81,7 @@ EOTEXT 'uri' => $linter->getInfoURI(), 'description' => $linter->getInfoDescription(), 'exception' => $exception, + 'options' => $linter->getLinterConfigurationOptions(), ); } @@ -137,10 +142,44 @@ EOTEXT $print_tail = true; } + $options = $linter['options']; + if ($options && $this->getArgument('verbose')) { + $console->writeOut( + "\n%s**%s**\n\n", + $pad, + pht('Configuration Options')); + + $last_option = last_key($options); + foreach ($options as $option => $option_spec) { + $console->writeOut( + "%s__%s__ (%s)\n", + $pad, + $option, + $option_spec['type']); + + $console->writeOut( + "%s\n", + phutil_console_wrap( + $option_spec['help'], + strlen($pad) + 2)); + + if ($option != $last_option) { + $console->writeOut("\n"); + } + } + $print_tail = true; + } + if ($print_tail) { $console->writeOut("\n"); } } + + if (!$this->getArgument('verbose')) { + $console->writeOut( + "%s\n", + pht('(Run `arc linters --verbose` for more details.)')); + } }