Nicolas Steenlant > Catmandu > Catmandu::Cmd

Download:
Catmandu-0.9209.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source  

NAME ^

Catmandu::Cmd - A base class for extending the Catmandu command line

SYNOPSIS ^

 # To create
 $ catmandu hello_world

 # You need:
 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

 1;

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

SEE ALSO ^

Catmandu::Cmd::config , Catmandu::Cmd::convert , Catmandu::Cmd::count , Catmandu::Cmd::data , Catmandu::Cmd::delete , Catmandu::Cmd::export, Catmandu::Cmd::import , Catmandu::Cmd::move

syntax highlighting: