Reputation: 91
I have guessed multiple syntax variations to achieve this in a single line in the MAIN function. I know I could achieve it in two separate lines, but am looking for the cleaner solution and only having the one named parameter assigned the value where the other long named parameter argument is just a form of alias.
Below are variations that all fail to compile with several different error messages. They were all tested one by one and as the first line in the MAIN function:
Bool :A(:$opt-ALLDEBUG is alias<ALLDEBUG>) = False,
Bool :A(:$opt-ALLDEBUG) = False,
Bool (:$opt-ALLDEBUG is alias<ALLDEBUG>) = False,
Bool :A(:$ALLDEBUG) = False,
Bool :opt-ALLDEBUG(:-A :ALLDEBUG) = False,
Bool :opt-ALLDEBUG(:-A :ALLDEBUG),
Bool :opt-ALLDEBUG(-A :ALLDEBUG),
Bool :opt-ALLDEBUG(:ALLDEBUG -A ),
Bool :opt-ALLDEBUG(:ALLDEBUG -:A ),
Bool :opt-ALLDEBUG(:ALLDEBUG -:A),
Bool :opt-ALLDEBUG(:ALLDEBUG),
Bool :opt-ALLDEBUG(:ALLDEBUG),
Bool :$opt-ALLDEBUG(:ALLDEBUG),
Bool :$opt-ALLDEBUG :ALLDEBUG,
Bool :$opt-ALLDEBUG :$ALLDEBUG,
Bool :$opt-ALLDEBUG :$ALLDEBUG = False,
Bool :$opt-ALLDEBUG (:$ALLDEBUG :A) = False,
Bool :$opt-ALLDEBUG (:$ALLDEBUG :-A) = False,
Bool :A(:$opt-ALLDEBUG :$ALLDEBUG) = False,
Bool :$opt-ALLDEBUG(:A, :$ALLDEBUG) = False,
Bool :$opt-ALLDEBUG(:A :$ALLDEBUG) = False,
Bool :A(:$opt-ALLDEBUG) (:$ALLDEBUG) = False,
Bool :$opt-ALLDEBUG (:$ALLDEBUG) = False,
Bool :$opt-ALLDEBUG (:$ALLDEBUG),
Upvotes: 9
Views: 375
Reputation: 5726
You can nest the aliasing as shown below. Note that as far as raku is concerned there is no difference between short options with -
and long options with --
and they can be used interchangeably
$ raku -e 'sub MAIN(Bool :A(:opt-ALLDEBUG(:$ALLDEBUG)) = False) { say $ALLDEBUG }'
False
$ raku -e 'sub MAIN(Bool :A(:opt-ALLDEBUG(:$ALLDEBUG)) = False) { say $ALLDEBUG }' -A
True
$ raku -e 'sub MAIN(Bool :A(:opt-ALLDEBUG(:$ALLDEBUG)) = False) { say $ALLDEBUG }' --opt-ALLDEBUG
True
$ raku -e 'sub MAIN(Bool :A(:opt-ALLDEBUG(:$ALLDEBUG)) = False) { say $ALLDEBUG }' --ALLDEBUG
True
Also see https://docs.raku.org/language/signatures#Argument_aliases
Upvotes: 11