jjmerelo
jjmerelo

Reputation: 23517

Unreachable command line option in MAIN

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?

Upvotes: 7

Views: 137

Answers (1)

Elizabeth Mattijsen
Elizabeth Mattijsen

Reputation: 26924

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 ($, *@)) { ... }

?

Upvotes: 5

Related Questions