Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds RUN-MAIN refs #2632
  • Loading branch information
JJ committed Mar 2, 2019
1 parent ccd207a commit f890b65
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions doc/Language/create-cli.pod6
Expand Up @@ -325,6 +325,42 @@ yourself, or by importing one from any of the
L<Getopt|https://modules.perl6.org/search/?q=getopt> modules available in the
ecosystem.
X<|RUN-MAIN>
=head2 sub RUN-MAIN
Defined as:
sub RUN-MAIN(&main, $mainline, :$in-as-argsfiles)
This routine allows complete control over the handling of C<MAIN>. It gets a
C<Callable> that is the MAIN that should be executed, the return value of the
mainline execution and additional named variables: C<:in-as-argsfiles> which
will be C<True> if STDIN should be treated as C<$*ARGFILES>.
If C<RUN-MAIN> is not provided, a default one will be run that looks for
subroutines of the old interface, such as C<MAIN_HELPER> and C<USAGE>. If
found, will execute following the "old" semantics.
=begin code
class Hero {
has @!inventory;
has Str $.name;
submethod BUILD( :$name, :@inventory ) {
$!name = $name;
@!inventory = @inventory
}
}
sub new-main($name, *@stuff ) {
Hero.new(:name($name), :inventory(@stuff) ).perl.say
}
RUN-MAIN( &new-main, Nil );
=end code
This will print the name (first argument) of the generated object.
X<|GENERATE-USAGE>
=head2 sub GENERATE-USAGE
Expand Down

0 comments on commit f890b65

Please sign in to comment.