Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop use of = in parsing arguments in raku

Tags:

raku

The fact that you can write in raku the following

unit sub MAIN(Int $j = 2);

say $j

is amazing, and the fact that the argument parsing is done for you is beyond useful. However I find personally extremely unergonomic that for such arguments you habe to write a = to set the value, i.e.

./script.raku -j=5

I was wondering if there is a way to tell the parser that it should allow options without the = so that I can write

./script.raku -j 5

I haven't seen this in the docs and this would really be much more intuitive for some people like me. If it is not currently possible, I think it would be a useful add-on.

like image 837
margolari Avatar asked May 11 '20 12:05

margolari


2 Answers

You could also use SuperMAIN, a library for CLI processing. This add some new superpowers to MAIN

like image 170
SmokeMachine Avatar answered Nov 17 '22 07:11

SmokeMachine


There has been a lot of discussion of how command line parameters should be parsed. At the moment there are no plans of adding more functionality to what Raku provides out of the box.

If you want more tweakability, you should probably look at the Getopt::Long module by Leon Timmermans

like image 24
Elizabeth Mattijsen Avatar answered Nov 17 '22 06:11

Elizabeth Mattijsen