Skip to content

Commit 2da299a

Browse files
committed
begin docing sub MAIN
1 parent 68ae004 commit 2da299a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/Language/functions.pod

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,19 @@ as the target type. So you can define coercions for your own types like so:
714714
Coercion types are supposed to work wherever types work, but Rakudo
715715
currently (2015.02) only implements them for subroutine parameters.
716716
717+
=head1 C<sub MAIN>
718+
719+
The sub with the special name C<MAIN> is executed after all relevant phaser
720+
and it's signature is the means by which command line arguments can be parsed.
721+
Multi methods are supported and a usage method is automatically generated and
722+
displayed if no command line arguments are provided.
723+
724+
sub MAIN ( Int :$length = 24, :file($data) = 'file.dat', Bool :$verbose ) {
725+
say $length if $length.defined;
726+
say $data if $data.defined;
727+
say 'Verbosity ', ($verbose ?? 'on' !! 'off');
728+
}
729+
717730
=end pod
718731

719732
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)