Catmandu::Cmd3pm
A base class for extending the catmandu command line
Usage
# 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 NAMECatmandu::Cmd::hello_world - prints a funny line=cut
Overview
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
log()
Access to the logger
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.
description()
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
Releases
6 releases since Debian 8 (Jessie); the text changed 5 times.