Skip to content

Commit

Permalink
Merge pull request #13 from hans-d/add_standard_config
Browse files Browse the repository at this point in the history
Make the syntax standard to comply with configurable.
  • Loading branch information
nateabele committed Jun 18, 2012
2 parents d0dbd6f + cf64be4 commit 93163b1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion extensions/command/Syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 93163b1

Please sign in to comment.