Here's a little trick that will allow you to add your default values to the usage message in Raku. Unfortunately, this has to be done by example.
sub USAGE {
my $u = $*USAGE;
for &MAIN.signature.params -> $p {
given $p.name {
when '$port' {
if $p.default -> $d {
$u .= subst(
'port to bind to',
"port to bind to [default = { $d() }]"
);
}
}
}
}
$u.say;
}
sub MAIN (
Str $root-directory, #= Root directory for server
Int :p(:$port) = 8080 #= Local port to bind to
) {
...
}
The advantage of this method is that if I change the value '8080' in MAIN'S signature, the USAGE message will update, as well. It's not a complete solution as yet, and a better way would be to do this at generation time, but it will work until someone improves on it.
Have a great day!