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.