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

@@ -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;
}
}
}