I run programs all the time from the command line that allow your to mix the order of the parameters. And they catch you if you throw something extra into the mix. For example:
$xxx -r abc -q def -w xyz
$xxx -w xyz -q def -r abc
How are they doing this? Is there some module for this?
Here is an example using Getopt::Long:
use v6;
use Getopt::Long;
my %opt = help => False, 'r=s' => "", 'q=s' => "", 'w=s' => "";
my %options = get-options(%opt).hash;
say %options;
say @*ARGS;
Example run:
$ p.p6 -w xyz -q def -r abc hello
{help => False, q => def, r => abc, w => xyz}
[hello]
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