/usr/share/perl5/Catmandu/Cmd.pm is in libcatmandu-perl 0.9206-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | package Catmandu::Cmd;
use Catmandu::Sane;
use parent qw(App::Cmd::Command);
# Internal required by App::Cmd
sub opt_spec {
my ($class, $cli) = @_;
(
['help|h|?', "print this usage screen"],
$cli->global_opt_spec,
$class->command_opt_spec($cli),
);
}
# Internal required by App::Cmd
sub execute {
my ($self, $opts, $args) = @_;
if ($opts->{version}) {
print $Catmandu::VERSION;
exit;
}
if ($opts->{help}) {
print $self->usage->text;
exit;
}
$self->command($opts, $args);
}
# These should be implemented by the Catmandu::Cmd's
sub description {}
sub command_opt_spec {}
sub command {}
=head1 NAME
Catmandu::Cmd - A base class for extending the Catmandu command line
=head1 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;
=head1 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
=head1 METHODS
=head2 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.
=head2 descripton()
This method should return a string containing the long documentation of the command
=head2 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.
=head1 DOCUMENTATION
At least provide for every command a NAME documentation
=head1 SEE ALSO
L<Catmandu::Cmd::config> , L<Catmandu::Cmd::convert> , L<Catmandu::Cmd::count> ,
L<Catmandu::Cmd::data> , L<Catmandu::Cmd::delete> , L<Catmandu::Cmd::export>,
L<Catmandu::Cmd::import> , L<Catmandu::Cmd::move>
=cut
1;
|