GENERATE-USAGE
ErrorsCollection

GENERATE-USAGE

Synthesised documentation from language/create-cli

From language/create-cli

See Original text in context

The GENERATE-USAGE subroutine should accept a Callable representing the MAIN subroutine that didn't get executed because the dispatch failed. This can be used for introspection. All the other parameters are the parameters that were set up to be sent to MAIN. It should return the string of the usage information you want to be shown to the user. An example that will just recreate the Capture that was created from processing the arguments:

sub GENERATE-USAGE(&main|capture{
    capture<foo>:exists
      ?? "You're not allowed to specify a --foo"
      !! &*GENERATE-USAGE(&main|capture)
}

You can also use multi subroutines to create the same effect:

multi sub GENERATE-USAGE(&main:$foo!{
    "You're not allowed to specify a --foo"
}
multi sub GENERATE-USAGE(&main|capture{
    &*GENERATE-USAGE(&main|capture)
}

Note that the dynamic variable &*GENERATE-USAGE is available to perform the default usage message generation so you don't have to reinvent the whole wheel if you don't want to.