I am trying to overload a function to detect no arguments have been passed:
package Documentable::CLI {
sub RUN-MAIN(|c) is export {
my %*SUB-MAIN-OPTS = :named-anywhere;
CORE::<&RUN-MAIN>(|c)
}
our proto MAIN(|) is export { * }
multi MAIN (
Bool :V(:$version)
) {}
multi MAIN () {
say 'Execute "documentable --help" for more information'
}
}
# no output
Documentable::CLI::MAIN();
If you try to use multi main (*@args) {}
it will not work either. BUT if you delete the first multi MAIN
definition everything will work smoothly. Any idea how to solve it?
The signature :(Bool :V(:$version))
accepts no argument, because the argument version
is optional, and it is more specific than the signature :()
. You could make the argument version
mandatory
multi MAIN (
Bool :V( :$version )!
) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With