Catmandu::Cmd(3pm)
π Catmandu::Cmd π
okay bestie, gather round, because we're talking about Catmandu::Cmd β a base class for extending the Catmandu command line β¨. This page lives in the User Contributed Perl Documentation section of the manual, and it's basically your starter pack for making catmandu do new tricks. iykyk π
πΈ SYNOPSIS πΈ
so the whole vibe is: you want a new command? say hi to catmandu hello_world. but first, bestie, you need a package π
# 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
that's the whole blueprint, no cap π«Ά
π¦ 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. lowkey the whole family tree lives in there π
Every command needs to implement 4 things, bestie, and the way that it's literally only four:
command_opt_specβ which should return an array of command options with documentationdescriptionβ a long description of the commandcommandβ the body which is executedhead1 NAMEβ a short description of the command
four things. that's it. that's the assignment β¨
β METHODS β
π log()
Access to the logger πͺ΅ β yes, you get a logger, you're welcome.
π 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. so if you're wondering why your command takes zero optionsβ¦ yeah. that's why. π
π 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. main character energy fr fr πβ¨
π DOCUMENTATION π
At least provide for every command a NAME documentation. just do it bestie, it's the bare minimum and it's giving "i respect my users" π
π SEE ALSO π
Catmandu::Cmd::configCatmandu::Cmd::convertCatmandu::Cmd::countCatmandu::Cmd::dataCatmandu::Cmd::deleteCatmandu::Cmd::exportCatmandu::Cmd::importCatmandu::Cmd::moveCatmandu::Cmd::run
go read them all, they ate π π¦
and that's the whole page, bestie!! πβ¨ this was Catmandu::Cmd(3pm) from perl v5.40.1, dated 2026-01-24 β mwah, obsessed, periodt ππ«Ά
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms