Skip to content

Commit 4d0a4d5

Browse files
committed
doc sub USAGE
1 parent b6f82b6 commit 4d0a4d5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

doc/Language/functions.pod6

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,6 @@ Coercion types are supposed to work wherever types work, but Rakudo
808808
currently (2015.02) only implements them for subroutine parameters.
809809
810810
=head1 C<sub MAIN>
811-
812811
X<|MAIN>X«|command line arguments»
813812
814813
The sub with the special name C<MAIN> is executed after all relevant phasers,
@@ -833,6 +832,23 @@ call L<exit|https://docs.perl6.org/routine/exit>.
833832
exit 1;
834833
}
835834
835+
=head1 C<sub USAGE>
836+
X<|USAGE>
837+
838+
If the no multi candidate of C<MAIN> is found for the given command line
839+
parameters, the sub C<USAGE> is called. If no such method is found, output a
840+
generated usage message.
841+
842+
sub MAIN(Int $i){ say $i == 42 ?? 'answer' !! 'dunno' }
843+
844+
sub USAGE(){
845+
print Q:c:to/EOH/;
846+
Usage: {$*PROGRAM-NAME} [number]
847+
848+
Prints the answer or 'dunno'.
849+
EOH
850+
}
851+
836852
=end pod
837853

838854
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)