Multiple MAIN signatures

前端 未结 1 1077
难免孤独
难免孤独 2020-12-20 18:41

I have a package with multiple main and I want to define several options:

My code is something like this:

package Perl6::Documentable::CLI {
    prot         


        
相关标签:
1条回答
  • 2020-12-20 19:14

    The simplest solution would be to export the dynamic variable %*SUB-MAIN-OPTS, but that is still Not Yet Implemented completely: the export works sorta, but winds up being an empty hash. So not very useful.

    Rakudo will call a subroutine called RUN-MAIN when it decides there is a MAIN sub to be run. You can actually export a RUN-MAIN from your module, and set up the dynamic variable, and then call the original RUN-MAIN:

    sub RUN-MAIN(|c) is export {
        my %*SUB-MAIN-OPTS = :named-anywhere;
        CORE::<&RUN-MAIN>(|c)
    }
    

    For more information about RUN-MAIN, see: https://docs.raku.org/language/create-cli#index-entry-RUN-MAIN

    0 讨论(0)
提交回复
热议问题