Skip to content

Commit

Permalink
Add a pager option to the kit-manual command
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisjbell committed Apr 30, 2024
1 parent 18a4ae9 commit f32e672
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bin/genesis
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ define_command("kit-manual", {
option_group => Genesis::Commands::REPO_OPTIONS,
options => [
'raw' =>
"Print the raw manual instead of rendering it in markdown."
"Print the raw manual instead of rendering it in markdown.",
'pager|P' =>
"Use a pager to display the manual."
],
no_vault => 1
});
Expand Down
9 changes: 8 additions & 1 deletion lib/Genesis/Commands/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,14 @@ sub kit_manual {
my $man = $kit->path('MANUAL.md');
if (-f $man) {
my $man_contents = slurp($man);
output get_options->{raw} ? $man_contents : render_markdown($man_contents);
my $contents = get_options->{raw} ? $man_contents : render_markdown($man_contents);
if (get_options->{pager}) {
open my $pager, "|-", "less -R" or die "Can't open pager: $!";
print $pager $contents;
close $pager;
} else {
output $contents;
}
exit 0;
}
error "#Y{%s} has no MANUAL.md", $kit->id;
Expand Down

0 comments on commit f32e672

Please sign in to comment.