markdown-resume/bin/md2resume

48 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env php
<?php
2015-03-16 09:23:51 -04:00
error_reporting(E_ALL | E_STRICT);
$baseDir = dirname(__DIR__);
$cwd = getcwd();
$templatePath = $baseDir . '/templates';
$consoleTemplatePath = $baseDir . '/src/Resume/Templates';
// When md2resume is installed with composer, it resides in the a
// 'markdown-resume' subdirectory of the 'vendor' directory, so we need to
// walk up a few folders to find 'autoload.php'.
$autoloadPath = basename($baseDir) === 'markdown-resume'
? realpath($baseDir . '/../../autoload.php')
: $baseDir . '/vendor/autoload.php';
2015-03-16 09:23:51 -04:00
// If the dependencies aren't installed, we have to bail and offer some help.
if (!file_exists($autoloadPath)) {
exit("\nThe dependency '$autoloadPath' was not found. Please run `composer install` to install dependencies.\n\n");
2015-03-16 09:23:51 -04:00
}
// Bootstrap our application with the Composer autoloader
$app = include $autoloadPath;
2015-03-16 09:23:51 -04:00
// Setup the namespace for our own namespace
$app->add('Resume', $baseDir . '/src');
2015-03-16 09:23:51 -04:00
// Instantiate our Console application
$console = new Resume\Cli\Resume();
// Fetch the version
chdir($baseDir);
$versionCmd = 'git describe --abbrev=0 --tags 2>/dev/null';
$version = trim(shell_exec($versionCmd));
chdir($cwd);
2015-03-16 09:23:51 -04:00
// Fetch the project name and description
$project = json_decode(file_get_contents(__DIR__ . '/../composer.json'));
$project->version = $version;
2015-03-16 09:23:51 -04:00
// Init the app with these params
$console->initialize($templatePath, $consoleTemplatePath, $project);
// Execute the console app.
$console->run();
/* End of resume.php */