Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

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:

  • Allow named parameters to be used everywhere instead of only after the positional parameters (corresponds with %SUB-MAIN-OPTS<named-anywhere> = True):
$ prog.raku <positional> [--named1=<Str>] [--named2=<Str>]
$ prog.raku [--named1=<Str>] [--named2=<Str>] <positional>
$ prog.raku [--named1=<Str>] <positional> [--named2=<Str>] 
  • Allow spaces as separator between a named parameter and its values (the Raku default is to only accept '=' as the separator).
$ prog.raku [--named1=<Str>]
$ prog.raku [--named1 <Str>] 
  • Auto-alias named parameters without the need to declare an alias, e.g. to make -n an alias of --named, you need to declare the alias in the signature:
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
$ cd SuperMAIN
$ zef install .