Catmandu::Cmd(3) A base class for extending the Catmandu command line


# to create a command:
$ catmandu hello_world
# you need a package:
package Catmandu::Cmd::hello_world;
use parent 'Catmandu::Cmd';
sub command_opt_spec {
[ "greeting|g=s", "provide a greeting text" ],
sub description {
catmandu hello_world --greeting "Hoi"
sub command {
my ($self, $opts, $args) = @_;
my $greeting = $opts->greeting // 'Hello';
print "$greeting, World!\n"
=head1 NAME
Catmandu::Cmd::hello_world - prints a funny line


Catmandu:Cmd is a base class to extend the commands that can be provided for the 'catmandu' command line tools. New catmandu commands should be defined in the Catmandu::Cmd namespace and extend Catmandu::Cmd.

Every command needs to implement 4 things:

  * command_opt_spec - which should return an array of command options with documentation
  * description - a long description of the command
  * command - the body which is executed 
  * head1 NAME - a short description of the command



This method should be overridden to provide option specifications. (This is list of arguments passed to describe_options from Getopt::Long::Descriptive, after the first.)

If not overridden, it returns an empty list.


This method should return a string containing the long documentation of the command


This method does whatever it is the command should do! It is passed a hash reference of the parsed command-line options and an array reference of left over arguments.


At least provide for every command a NAME documentation