Re: checking MAIN arguments

2022-04-28 Thread Luca Ferrari
On Wed, Apr 27, 2022 at 7:29 PM yary wrote: > It's like the "where" clause has its own signature-like list of types it will > accept. When the where clause uses the default topic "$_" then that topic has > no constraint, and MAIN can probe if "--dir=something" should be interpreted > as a flag

Re: checking MAIN arguments

2022-04-27 Thread yary
I just read through https://github.com/rakudo/rakudo/issues/4878 and I had a thought. It's like the "where" clause has its own signature-like list of types it will accept. When the where clause uses the default topic "$_" then that topic has no constraint, and MAIN can probe if "--dir=something" s

Re: checking MAIN arguments

2022-04-16 Thread Luca Ferrari
On Fri, Apr 15, 2022 at 4:15 PM yary wrote: > > Here's how I ended up handling input arg validation, with meaningful error > messages, as part of a Perl Weekly Challenge a couple years ago. It looks > almost the same as Luca's original, except mine uses "die" instead of "warn", > which means it

Re: checking MAIN arguments

2022-04-15 Thread yary
Here's how I ended up handling input arg validation, with meaningful error messages, as part of a Perl Weekly Challenge a couple years ago. It looks almost the same as Luca's original, except mine uses "die" instead of "warn", which means it won't attempt to continue once it encounters a bad arg.

Re: checking MAIN arguments

2022-04-14 Thread William Michels via perl6-users
Works (𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.06): admin@mbook:~$ raku Luca_Ferrari2.p6 Usage: Luca_Ferrari2.p6 [--dir=] admin@mbook:~$ raku Luca_Ferrari2.p6 --dir=foo foo But...warning "Specify the directory [$dir]" isn't printing when `--dir=foo` is omitted. HTH, Bill. On Tue, Apr 12, 2022 at 1:23 AM Luca Ferrari

Re: checking MAIN arguments

2022-04-14 Thread William Michels via perl6-users
Fails on 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.06. ~$ raku Luca_Ferrari.p6 Use of uninitialized value of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. in block at Luca_Ferrari.p6 line 1 Specify the directory [] in block at Luca_Ferrari.p6 line

Re: checking MAIN arguments

2022-04-12 Thread Luca Ferrari
On Tue, Apr 12, 2022 at 10:15 AM Luca Ferrari wrote: > > Hello all, > given this simple program: > > sub MAIN( Str :$dir where { .so && .IO.d // warn "Specify the > directory [$dir]" } ) { > say $dir; > } > Shame on me: it works if I omit the topic and substitute it with the explicit variable

checking MAIN arguments

2022-04-12 Thread Luca Ferrari
Hello all, given this simple program: sub MAIN( Str :$dir where { .so && .IO.d // warn "Specify the directory [$dir]" } ) { say $dir; } it works as I expect on ancient versions of rakudo, e.g., 202-01, but it fails miserably on current rakudo: % raku ~/tmp/test.p6 --dir=foo Use of uninitiali