RUN-MAIN
ErrorsCollection

RUN-MAIN

Synthesised documentation from language/create-cli

From language/create-cli

See Original text in context

sub RUN-MAIN(&main$mainline:$in-as-argsfiles)

This routine allows complete control over the handling of MAIN. It gets a Callable that is the MAIN that should be executed, the return value of the mainline execution and additional named variables: :in-as-argsfiles which will be True if STDIN should be treated as $*ARGFILES.

If RUN-MAIN is not provided, a default one will be run that looks for subroutines of the old interface, such as MAIN_HELPER and USAGE. If found, it will execute following the "old" semantics.

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) ).raku.say
}
 
RUN-MAIN&new-mainNil );

This will print the name (first argument) of the generated object.