Skip to content
Browse files

Merge pull request #13 from hans-d/add_standard_config

Make the syntax standard to comply with configurable.
  • Loading branch information...
2 parents d0dbd6f + cf64be4 commit 93163b1dc1f9d4c0f0faa10dfe4db8097c658f6b @nateabele nateabele committed Jun 17, 2012
Showing with 36 additions and 1 deletion.
  1. +36 −1 extensions/command/Syntax.php
View
37 extensions/command/Syntax.php
@@ -55,6 +55,13 @@ class Syntax extends \lithium\console\Command implements \spriebsch\PHPca\Progre
*/
public $php;
+ /**
+ * Alternative syntax standards to use.
+ *
+ * @var string
+ */
+ public $standard;
+
protected $_project;
protected $_vcs;
@@ -83,7 +90,7 @@ public function run() {
$app = new Application(getcwd());
$app->registerProgressPrinter($this);
- $file = Libraries::get('phpca', 'path') . '/Standard/lithium.ini';
+ $file = $this->_standard();
$config = new Configuration(getcwd());
$config->setStandard(parse_ini_file($file, true));
@@ -117,6 +124,34 @@ public function run() {
return !$result->hasErrors();
}
+ protected function _standard() {
+ $default = Libraries::get('phpca', 'path') . '/Standard/lithium.ini';
+ $config = Libraries::get('li3_qa') + array('standard' => false);
+ $notFound = ' Could not find `{:standard}`.';
+ $nextBest = ' Using `{:standard}` instead.';
+ $message = '';
+
+ foreach (array($this->standard, $config['standard']) as $standard) {
+ if (!$standard) {
+ continue;
+ }
+ if (file_exists($standard)) {
+ if ($message) {
+ $message .= String::insert($nextBest, compact('standard'));
+ $this->error(trim($message));
+ }
+ return $standard;
+ }
+ $message .= String::insert($notFound, compact('standard'));
+ }
+ if ($message) {
+ $standard = 'Lithium defaults';
+ $message .= String::insert($nextBest, compact('standard'));
+ $this->error(trim($message));
+ }
+ return $default;
+ }
+
public function showProgress($file, Result $result, Application $application) {
$message = str_replace($this->_project . '/', null, $file);
$self = $this;

0 comments on commit 93163b1

Please sign in to comment.
Something went wrong with that request. Please try again.