File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -985,6 +985,7 @@ C<MAIN> sub but the resulting exit code will always be zero (success).
985
985
To provide an exit code different from 0,
986
986
call L < exit|https://docs.perl6.org/routine/exit > .
987
987
988
+ #|(optional description for USAGE message)
988
989
sub MAIN( Int :$length = 24,
989
990
:file($data) where { .IO.f // die "file not found in $*CWD" } = 'file.dat',
990
991
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
1032
1033
parameters, the sub C < USAGE > is called. If no such method is found,
1033
1034
the compiler will output a default generated usage message.
1034
1035
1035
- sub MAIN(Int $i){ say $i == 42 ?? 'answer' !! 'dunno' }
1036
+ #|(is it the answer)
1037
+ multi MAIN(Int $i){ say $i == 42 ?? 'answer' !! 'dunno' }
1038
+ #|(divide two numbers)
1039
+ multi MAIN($a, $b){ say $a/$b }
1036
1040
1037
1041
sub USAGE(){
1038
1042
print Q:c:to/EOH/;
@@ -1043,7 +1047,9 @@ the compiler will output a default generated usage message.
1043
1047
}
1044
1048
1045
1049
The default usage message is available inside C < sub USAGE > via read-only
1046
- C < $*USAGE > variable.
1050
+ C < $*USAGE > variable. It will be generated based on available C < sub MAIN >
1051
+ candidates and their parameters. You can specify additional extended
1052
+ description for each candidate using C < #|(...) > Pod block to set L < WHY > .
1047
1053
1048
1054
= end pod
1049
1055
You can’t perform that action at this time.
0 commit comments