diff --git a/src/lint/linter/ArcanistExternalLinter.php b/src/lint/linter/ArcanistExternalLinter.php --- a/src/lint/linter/ArcanistExternalLinter.php +++ b/src/lint/linter/ArcanistExternalLinter.php @@ -12,6 +12,7 @@ private $bin; private $interpreter; + private $interpreterArguments; private $flags; private $versionRequirement; @@ -197,6 +198,45 @@ return $this; } + /** + * Return the default interpreter arguments. + * + * This method is only invoked if @{method:shouldUseInterpreter} has been + * overridden to return `true`. + * + * @return list Interpreter arguments. + * @task bin + */ + public function getDefaultInterpreterArguments() { + return array(); + } + + /** + * Get the effective interpreter arguments. + * + * This method synthesizes configuration and defaults. + * + * @return list Effective interpreter arguments. + * @task bin + */ + final public function getInterpreterArguments() { + return coalesce( + $this->interpreterArguments, + $this->getDefaultInterpreterArguments()); + } + + /** + * Set the interpreter arguments, overriding any default. + * + * @param list New interpreter arguments. + * @return this + * @task bin + */ + final public function setInterpreterArguments(array $arguments) { + $this->interpreterArguments = $arguments; + return $this; + } + /* -( Parsing Linter Output )---------------------------------------------- */ @@ -353,12 +393,13 @@ $interpreter = null; if ($this->shouldUseInterpreter()) { $interpreter = $this->getInterpreter(); + $interpreter_args = $this->getInterpreterArguments(); } $binary = $this->getBinary(); if ($interpreter) { - $bin = csprintf('%s %s', $interpreter, $binary); + $bin = csprintf('%s %Ls %s', $interpreter, $interpreter_args, $binary); } else { $bin = csprintf('%s', $binary); } @@ -495,6 +536,10 @@ 'a list of possible interpreters, the first one that exists '. 'will be used.'), ); + $options['interpreter.arguments'] = array( + 'type' => 'optional list', + 'help' => pht(''), + ); } return $options + parent::getLinterConfigurationOptions(); @@ -521,6 +566,10 @@ throw new Exception( pht('None of the configured interpreters can be located.')); + case 'interpreter.arguments': + $this->interpreterArguments = $value; + return; + case 'bin': $is_script = $this->shouldUseInterpreter();