#! /usr/bin/env perl6

use v6.c;

#| Render a Perl 6 program's pod structure.
sub MAIN (
	#| Path to the Perl 6 program or POD file.
	Str:D $file,

	#| Don't pipe output to a pager.
	Bool:D :$skip-pager = False,
) {
	my Str $command = "'$*EXECUTABLE' --doc=Pager '$file'";

	if (!$skip-pager) {
		my Str $pager = %*ENV<PAGER> // ($*DISTRO.is-win ?? 'more' !! 'less -r');

		$command ~= " | $pager";
	}

	shell $command;
}

=begin pod

=NAME    p6man
=AUTHOR  Patrick Spek <p.spek@tyil.work>
=VERSION 0.2.0
=LICENSE GNU Aferro General Public License, version 3

=head1 Synopsis

=item1 p6man --help
=item1 p6man [--skip-pager] <file>

=head1 Description

C<p6man> is a Perl 6 utility to generate manual-like information on a Perl 6
program or module, based on it's pod structure.

=head1 Examples

    p6man p6man

=head1 See also

=item1 L<p6doc|https://github.com/perl6/doc/blob/master/bin/p6doc>

=end pod

# vim: ft=perl6 noet
