The multi sub MAIN()
command line parsing in Perl6 is sweet!
As far as I can tell from the Command Line Interface docs there is only one option supported in the dynamic hash %*SUB-MAIN-OPTS to manipulate the option processing (that being :named-anywhere
).
Perhaps I've missed the obvious, but is there an existing/supported option to take 'old fashioned' single dash options?
For example:
#Instead of this...
myprogram.p6 --alpha=value1 --beta==value2 --chi
#... short options like this
myprogram.p6 -a value1 -bvalue2 -c
Or is this best processed manually or with an external module?
You can sort of emulate this as-is, although you still have to an = ala -a=foo
, and still technically have --a=foo
in addition to --alpha
and -a
sub MAIN(:a(:$alpha)!) {
say $alpha;
}
...so you probably want to use https://github.com/Leont/getopt-long6
use Getopt::Long;
get-options("alpha=a" => my $alpha);
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