Permalink
Browse files

Document sub MAIN usage cares about WHY on candidates

Looking at the code it also cares about .WHYs on individual
parameters, but I don't know Pod enough to figure out how to
set those.
  • Loading branch information...
zoffixznet committed Jan 13, 2018
1 parent c0184ad commit ec139cb312ba44d9daeed11691e87a4212e3adda
Showing with 8 additions and 2 deletions.
  1. +8 −2 doc/Language/functions.pod6
@@ -985,6 +985,7 @@ C<MAIN> sub but the resulting exit code will always be zero (success).
To provide an exit code different from 0,
call L<exit|https://docs.perl6.org/routine/exit>.
#|(optional description for USAGE message)
sub MAIN( Int :$length = 24,
:file($data) where { .IO.f // die "file not found in $*CWD" } = 'file.dat',
Bool :v(:$verbose) #`( either --verbose or -v ) )
@@ -1032,7 +1033,10 @@ If no multi candidate of C<MAIN> is found for the given command line
parameters, the sub C<USAGE> is called. If no such method is found,
the compiler will output a default generated usage message.
sub MAIN(Int $i){ say $i == 42 ?? 'answer' !! 'dunno' }
#|(is it the answer)
multi MAIN(Int $i){ say $i == 42 ?? 'answer' !! 'dunno' }
#|(divide two numbers)
multi MAIN($a, $b){ say $a/$b }
sub USAGE(){
print Q:c:to/EOH/;
@@ -1043,7 +1047,9 @@ the compiler will output a default generated usage message.
}
The default usage message is available inside C<sub USAGE> via read-only
C<$*USAGE> variable.
C<$*USAGE> variable. It will be generated based on available C<sub MAIN>
candidates and their parameters. You can specify additional extended
description for each candidate using C<#|(...)> Pod block to set L<WHY>.
=end pod

0 comments on commit ec139cb

Please sign in to comment.