develooper Front page | perl.perl6.users | Postings from January 2020

How to process command line options

Thread Next
From:
David Santiago
Date:
January 5, 2020 22:32
Subject:
How to process command line options
Message ID:
CAO5X0j5HCerqfxjBqsFy7G038TZwHSvqqaWHC66kB0C1G2MYPA@mail.gmail.com
Hello.

I'm following https://docs.raku.org/language/5to6-nutshell#Getopt::Long
but i still haven't figured it out how do i use a constraint in a
named parameter when processing a command line.

I have this piece of code:

multi sub MAIN("apt",
                :$layout where $layout ~~
/^<[12345]>\+[kk|1]$|^6\+$|^[studio|unusual]$/ #= Apartment layout.
Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual
) {
    say "Enter";
}

however when i run it i get the --help message:

$ raku script.raku apt --layout '1+kk'
Usage:
  script.raku [--layout=<Any where { ... }>] apartment

  --layout=<Any where { ... }>    Apartment layout. Values accepted:
1+kk,2+kk,...,5+kk, 6+, studio, unusual


If i make layout a positional parameter then it works correctly. Is
there a way to make this work with a named parameter?
And how do i make possible to use the "--layout" option several times?
Changing the parameter from $layout to @layout doesn't work.



Best regards,
David Santiago

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About