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

SYNOPSIS


# 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 {
<<EOS;
examples:
catmandu hello_world --greeting "Hoi"
options:
EOS
}
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
=cut

DESCRIPTION

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

METHODS

command_opt_spec()

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.

descripton()

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

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.

DOCUMENTATION

At least provide for every command a NAME documentation