Here's something to play with (without explanation from me, busy enough
sorry!)


example.raku:
  multi sub MAIN(:$these ="These", :$are="Are") { say "$these $are"; };
  multi sub MAIN(*@wrong-list,:$these ="These", :$are="Are",*%wrong-named)
is hidden-from-USAGE
    {say "Got bad args " ~ @wrong-list ~ " "~ %wrong-named}'


raku example.raku -these=HIHIHI -foo=BABABA

-y


On Tue, May 5, 2020 at 1:09 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> >> On Tue, 5 May 2020, 06:46 ToddAndMargo via perl6-users,
> >> <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:
> >>
> >>     Hi All,
> >>
> >>     Just to prove I read the stinker:
> >>     https://docs.raku.org/routine/MAIN
> >>
> >>     I am trying to get the following to do
> >>
> >>     #!/usr/bin/env perl6
> >>     sub MAIN(:$these ="These", :$are="Are") { say "$these $are"; }
> >>
> >>     This is working:
> >>
> >>     $ MainTest.pl6 --are=our --these=those
> >>     those our
> >>
> >>
> >>     These two are not:
> >>
> >>     1) I am trying to get MAIN to give me an error I can
> >>          call my help sub if a stray entry is placed in
> >>          the run line
> >>
> >>     $ MainTest.pl6 --are=our --these=those --saywhat=abc
> >>     Usage:
> >>         MainTest.pl6 [--these=<Any>] [--are=<Any>]
> >>
> >>     Here it find `--saywhat=abc` and MAIN writes out the above
> >>     usage statement.
> >>
> >>          A) I want to write it out myself.  I would like the
> >>             string too, but don't have to have it.
> >>
> >>          B) I would like the stray entry.
> >>
> >>
> >>     2) Here I want to pick up the remainder (abc) at the end,
> >>          but can't figure out the syntax in the sub declaration.
> >>
> >>          Something like:
> >>                dnf --excluderepo=acb* install raku
> >>
> >>     $ MainTest.pl6 --are=our --these=those abc
> >>     Usage:
> >>         MainTest.pl6 [--these=<Any>] [--are=<Any>]
> >>
> >>     Instead of MAIN writing out usage.
> >>
> >>     Many thanks,
> >>     -T
> >>
>
> On 2020-05-05 00:38, Simon Proctor wrote:
> > I would suggest starting by reading this page in the docs :
> > https://docs.raku.org/language/create-cli
> >
> > Covers how $*USAGE is created and the various options you have for
> > providing help data.
> >
>
> Hi Simon,
>
> I must be missing something.  That is just a rehash of the manual page I
> first posted with a few extra paragraphs at he top.
>
> :'(
>
> Maybe I should just write my own based on @*ARGS  ?
>
> -T
>

Reply via email to