Catmandu::Cmd(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 documentation
  • description β€” a long description of the command
  • command β€” the body which is executed
  • head1 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::config
  • Catmandu::Cmd::convert
  • Catmandu::Cmd::count
  • Catmandu::Cmd::data
  • Catmandu::Cmd::delete
  • Catmandu::Cmd::export
  • Catmandu::Cmd::import
  • Catmandu::Cmd::move
  • Catmandu::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