Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unreachable command line option in MAIN

Tags:

syntax

raku

zef search includes :$update as a named argument:

 multi MAIN('search', Int :$wrap = False, :$update, *@terms ($, *@))

However, it's not recognized as such:

% zef search --update
Usage:
  /home/jmerelo/.rakudobrew/bin/../moar-2019.03.1/install/share/perl6/site/bin/zef [--wrap=<Int>] search [<terms> ...] -- Get a list of possible distribution candidates for the given terms
  /home/jmerelo/.rakudobrew/bin/../moar-2019.03.1/install/share/perl6/site/bin/zef [--version] -- Detailed version information
  /home/jmerelo/.rakudobrew/bin/../moar-2019.03.1/install/share/perl6/site/bin/zef [-h|--help]

What am I missing here? How could I assign a value to this $update?

like image 246
jjmerelo Avatar asked May 05 '19 08:05

jjmerelo


1 Answers

If I run this MAIN candidate by itself, it works:

$ perl6 -e 'multi MAIN("search", Int :$wrap = False, :$update, *@terms ($, *@)) { say "foo" }' search --update
foo

so it looks to me there is more than one candidate that matches, and that causes the USAGE feedback message to appear.

Named parameters are used as tie-breakers only, unless they are made mandatory (which makes them effectively a part of the dispatch process). So maybe the fix is to make two candidates:

multi MAIN('search', Int :$wrap = False, :$update!, *@terms ($, *@)) { ... }
multi MAIN('search', Int :$wrap = False,            *@terms ($, *@)) { ... }

?

like image 183
Elizabeth Mattijsen Avatar answered Sep 24 '22 12:09

Elizabeth Mattijsen