sub USAGE

Documentation for sub USAGE, assembled from the following types:

language documentation Functions

From Functions

(Functions) sub USAGE

If no multi candidate of MAIN is found for the given command line parameters, the sub USAGE is called. If no such method is found, the compiler will output a default generated usage message.

#|(is it the answer) 
multi MAIN(Int $i){ say $i == 42 ?? 'answer' !! 'dunno' }
#|(divide two numbers) 
multi MAIN($a$b){ say $a/$b }
 
sub USAGE(){
print Q:c:to/EOH/; 
Usage: {$*PROGRAM-NAME} [number]
 
Prints the answer or 'dunno'.
EOH
}

The default usage message is available inside sub USAGE via read-only $*USAGE variable. It will be generated based on available sub MAIN candidates and their parameters. You can specify additional extended description for each candidate using #|(...) Pod block to set WHY.