Add initial html command processing

This command is going to be quite similar to the pdf command, and we’ll
need to abstract and extend this soon.
This commit is contained in:
Craig Davis 2014-01-12 09:55:31 -07:00
parent 8f43dc5c29
commit 842fae2b6f
4 changed files with 71 additions and 4 deletions

View File

@ -30,6 +30,29 @@ at the [blog post for the project][blog].
## Help
Markdown Resume Generator version 2.0.0 by Craig Davis
Usage:
[options] command [arguments]
Options:
--help -h Display this help message.
--quiet -q Do not output any message.
--verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version -V Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction -n Do not ask any interactive question.
Available commands:
help Displays help for a command
html Generate an HTML resume from a markdown file
list Lists commands
pdf Generate a PDF from a markdown file
selfupdate Updates fb.phar to the latest version.
templates List available templates
version Show current version information
## Examples
Choose a template with the -t option.
@ -55,6 +78,12 @@ use a CSS rules to display a very nice resume. Note that because we have very
few ways to nest or identify elements that many of the css rules are based
on descendant and adjacent selectors.
## Development Dependencies
* composer install
* pear install PHP_CodeSniffer
* [install pake][pake]
## TODO
* Google Analytics include
@ -79,3 +108,4 @@ have been added. It's a nice template, and if you are a more comfortable with ht
[srt]: http://sampleresumetemplate.net/ "A great starting point"
[blog]: http://there4development.com/blog/2012/12/31/markdown-resume-builder/
[pake]: https://github.com/indeyets/pake/wiki/Installing-Pake

View File

@ -70,7 +70,7 @@ function run_phar()
function run_sniff()
{
echo " * Checking files for PSR2\n";
passthru("phpcs -p --standard=PSR2 ./src/ ./working.php");
passthru("phpcs -p --standard=PSR2 ./src/ ./resume.php");
}
function run_fixer()
@ -87,7 +87,7 @@ function run_readme()
{
echo " * Updating README documentation\n";
$readme = file("README.md");
$help = explode("\n", shell_exec("php ./working.php list --no-interaction"));
$help = explode("\n", shell_exec("php ./resume2.php list --no-interaction"));
$helpStart = $helpEnd = 0;
foreach ($readme as $lineNumber => $line) {

View File

@ -14,6 +14,8 @@ use Resume\Command;
class Resume extends Application
{
public $defaultTemplate = 'modern';
public $recentCaseLimit = 10;
public function initialize($templatePath, $consoleTemplatePath, $project)

View File

@ -21,14 +21,14 @@ class HtmlCommand extends Command
'Source markdown document'
)
->addArgument(
'output',
'destination',
InputArgument::REQUIRED,
'Output html document'
)
->addOption(
'template',
't',
InputOption::VALUE_NONE,
InputOption::VALUE_OPTIONAL,
'Which of the templates to use'
)
->addOption(
@ -42,6 +42,41 @@ class HtmlCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->app = $this->getApplication();
$source = $input->getArgument('source');
$destination = $input->getArgument('destination');
$template = $input->getOption('template');
$refresh = $input->getOption('refresh');
// Check that the source file is sane
if (!file_exists($source)) {
$output->writeln(
sprintf(
"<error>Unable to open source file: %s</error>",
$source
),
$this->app->outputFormat
);
return false;
}
// Check that our template is sane, or set to the default one
if (!$template) {
$template = $this->app->defaultTemplate;
}
$templatePath = join(DIRECTORY_SEPARATOR, array(
$this->app->templatePath, basename($template), '/index.html'
));
if (!file_exists($templatePath)) {
$output->writeln(
sprintf(
"<error>Unable to open template file: %s</error>",
$templatePath
),
$this->app->outputFormat
);
return false;
}
}
}