Add a new check for the mbstring dependency. Closes #20

This commit is contained in:
Craig Davis 2014-03-24 08:02:05 -05:00
parent 886fc223dd
commit 7103ee343e
2 changed files with 16 additions and 1 deletions

View File

@ -16,7 +16,7 @@ $app->add('Resume', __DIR__ . '/src');
$console = new Resume\Cli\Resume();
// If we're running from phar, we get these values from the stub
if (!defined("IN_PHAR")) {
if (!defined('IN_PHAR')) {
$project = json_decode(file_get_contents(__DIR__ . '/composer.json'));
}

View File

@ -30,6 +30,9 @@ class Resume extends Application
// the alternative is OutputInterface::OUTPUT_PLAIN;
$this->outputFormat = OutputInterface::OUTPUT_NORMAL;
// Exits on missing dependencies
$this->checkDependencies();
// We do this now because we've loaded the project info from the composer file
$this->setName($this->project->description);
$this->setVersion($this->project->version);
@ -65,6 +68,18 @@ class Resume extends Application
return parent::getLongVersion().' by <comment>Craig Davis</comment>';
}
public function checkDependencies() {
$output = new ConsoleOutput();
if (!extension_loaded('mbstring')) {
$output->writeln(
"\n<error>Missing Dependency: Please install the Multibyte String Functions.</error>\n" .
"More help: http://www.php.net/manual/en/mbstring.installation.php\n",
$this->outputFormat
);
exit(1);
}
}
public function registerStyles(&$output)
{
// https://github.com/symfony/Console/blob/master/Formatter/OutputFormatterStyle.php