/usr/share/perl5/Spoon/Command.pm is in libspoon-perl 0.24-2.
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 | package Spoon::Command;
use Spoon::Base -Base;
field quiet => 0;
sub process {
no warnings 'once';
local *boolean_arguments = sub { qw( -q -quiet ) };
my ($args, @values) = $self->parse_arguments(@_);
$self->quiet(1)
if $args->{-q} || $args->{-quiet};
my $action = $self->get_action(shift(@values)) ||
sub { $self->default_action(@_) };
$action->(@values);
return $self;
}
sub get_action {
my $action = shift
or return;
$action =~ s/^-//
or return;
my $method = "handle_$action";
return sub {
$self->$method(@_);
} if $self->can($method);
my $array = $self->hub->registry->lookup->{command}{$action}
or return;
my $class_id = shift @$array;
my $object = $self->hub->$class_id;
return sub {
$object->$method(@_);
};
}
sub default_action {
$self->usage;
}
sub command_usage {
my $pattern = shift;
my $lookup = $self->hub->registry->lookup;
my $commands = $lookup->{command} || {};
my %descriptions = map {
my $array = $commands->{$_};
shift @$array;
my %hash = @$array;
my $description = $hash{description} || '';
($_, $description);
} keys %$commands;
my $usage = '';
for my $plugin (@{$lookup->plugins}) {
my $class_id = $plugin->{id};
for my $command (@{$lookup->add_order->{$class_id}{command}}) {
$usage .= sprintf($pattern, $command, $descriptions{$command});
}
}
return $usage;
}
sub msg {
warn @_ unless $self->quiet;
}
__DATA__
=head1 NAME
Spoon::Command - Spoon Command Line Tool Module
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 AUTHOR
Brian Ingerson <INGY@cpan.org>
=head1 COPYRIGHT
Copyright (c) 2004. Brian Ingerson. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
=cut
|