markdown-resume/bin/md2resume

48 lines
1.5 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
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';
// 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");
}
// Bootstrap our application with the Composer autoloader
$app = include $autoloadPath;
// Setup the namespace for our own namespace
$app->add('Resume', $baseDir . '/src');
// 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);
// Fetch the project name and description
$project = json_decode(file_get_contents(__DIR__ . '/../composer.json'));
$project->version = $version;
// Init the app with these params
$console->initialize($templatePath, $consoleTemplatePath, $project);
// Execute the console app.
$console->run();
/* End of resume.php */