Rand Stats



SuperMAIN, Raku MAIN() with superpowers

Build Status

MAIN is one of the many nice features that makes Raku a very fun language to work with. Command Line Interfaces (CLI) can be easily be created in a very intuitive way.

This module adds features to MAIN without changing the syntax (or semantics). Everything works as before, just with some nice-to-haves for the users of the CLI.


The following features were added to MAIN:

$ prog.raku <positional> [--named1=<Str>] [--named2=<Str>]
$ prog.raku [--named1=<Str>] [--named2=<Str>] <positional>
$ prog.raku [--named1=<Str>] <positional> [--named2=<Str>] 
$ prog.raku [--named1=<Str>]
$ prog.raku [--named1 <Str>] 
sub MAIN(Str :n(:$named)) { ... }

With SuperMain, an alias will be automatically created to the shortest unique parameter identifier, e.g. for the signature

sub MAIN(Str :$named, Str :$other-named )) { ... }

the alias "-n" and "-o" will be accepted. If MAIN already has an alias for a parameter no new alias will be created for that specific parameter.

$ prog.raku [--named=<Str>] [--other-named=<Str>]
$ prog.raku [-n=<Str>] [-o=<Str>]
$ prog.raku [--named <Str>] [--other-named <Str>]
$ prog.raku [-n <Str>] [-o <Str>]


Add this to the script handling the CLI:

use SuperMAIN;

# That's it: just use `sub MAIN` or `multi MAIN` as usual.


Through the ecosystem:

$ zef install SuperMAIN


$ git clone https://github.com/nxadm/SuperMAIN
$ cd SuperMAIN
$ zef install .