Skip to content

Commit 29406ea

Browse files
committed
Merge pull request #301 from MadcapJake/master
Yes this doesnt break anything ;)
2 parents 099bf5c + e089b27 commit 29406ea

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

bin/p6doc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ sub locate-module(Str $modulename) {
5252
return $m;
5353
}
5454

55-
sub show-docs(Str $path, :$section) {
56-
my $pager = %*ENV<PAGER> // ($*DISTRO.name eq 'mswin32' ?? 'more' !! 'less');
55+
sub show-docs(Str $path, :$section, :$no-pager) {
56+
my $pager = do if $no-pager.defined { 'cat' } else {
57+
%*ENV<PAGER> // ($*DISTRO.name eq 'mswin32' ?? 'more' !! 'less');
58+
}
5759
my $which-fmt = qq:x{which fmt}.chomp;
5860
my $fmt-string = $which-fmt.IO.e ?? "| $which-fmt -w 80 " !! "";
5961
if not open($path).lines.grep( /^'=' | '#|' | '#='/ ) {
@@ -80,9 +82,12 @@ multi sub MAIN() {
8082

8183
say "\nYou can also look up specific method/routine definitions:";
8284
say " $me -f push";
85+
86+
say "\nYou can bypass the pager and print straight to stdout:";
87+
say " $me -n Type::Str"
8388
}
8489

85-
multi sub MAIN($docee) {
90+
multi sub MAIN($docee, Bool :$n) {
8691
return MAIN($docee, :f) if defined $docee.index('.') ;
8792
if INDEX.IO ~~ :e {
8893
my %data = EVALFILE INDEX;
@@ -91,7 +96,11 @@ multi sub MAIN($docee) {
9196
return MAIN($newdoc);
9297
}
9398
}
94-
show-docs(locate-module($docee));
99+
if $n {
100+
show-docs(locate-module($docee), :no-pager)
101+
} else {
102+
show-docs(locate-module($docee));
103+
}
95104
}
96105

97106
multi sub MAIN($docee, Bool :$f!) {

0 commit comments

Comments
 (0)