Update pake to use a regex when writing the command help

Swap to using a fenced code block for the command output
This commit is contained in:
Craig Davis 2014-01-13 07:50:25 -07:00
parent 483c262619
commit 91b8fb6e2c
2 changed files with 35 additions and 43 deletions

View File

@ -23,32 +23,33 @@ at the [blog post for the project][blog].
./bin/md2resume pdf examples/source/sample.md examples/output/
## Help
```
Markdown Resume Generator version 2.0.0 by Craig Davis
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 md2resume.phar to the latest version.
stats Generate a word frequency analysis of your resume
templates List available templates
version Show current version information
## Examples
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 md2resume.phar to the latest version.
stats Generate a word frequency analysis of your resume
templates List available templates
version Show current version information
```
## Examples
Choose a template with the -t option.

View File

@ -93,25 +93,16 @@ function run_fixer()
function run_readme()
{
echo " * Updating README documentation\n";
$readme = file("README.md");
$help = explode("\n", shell_exec("php ./md2resume_dev.php list --no-interaction"));
$helpStart = $helpEnd = 0;
foreach ($readme as $lineNumber => $line) {
if (trim($line) == "## Help") {
$helpStart = $lineNumber;
continue;
}
if ($helpStart && (substr(trim($line), 0, 2) == "##")) {
$helpEnd = $lineNumber;
break;
}
}
$output = join(array_slice($readme, 0, $helpStart + 1));
$output .= "\n " . implode("\n ", $help) . "\n";
$output .= join(array_slice($readme, $helpEnd));
$startPoint = '## Help';
$endPoint = '## Examples';
$readme = file_get_contents("README.md");
$help = shell_exec("php ./md2resume_dev.php list --no-interaction");
$output = preg_replace(
'/('.preg_quote($startPoint).')(.*)('.preg_quote($endPoint).')/si',
"$1\n```\n" . $help . "\n```\n $3",
$readme
);
file_put_contents("README.md", $output);
}