Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a %*SUB-MAIN-OPTS pair for short option processing?

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?

like image 612
drclaw Avatar asked May 16 '19 23:05

drclaw


1 Answers

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);
like image 129
ugexe Avatar answered Nov 19 '22 22:11

ugexe