/usr/share/perl5/App/Cmd/Command/commands.pm is in libapp-cmd-perl 0.324-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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | use strict;
use warnings;
package App::Cmd::Command::commands;
$App::Cmd::Command::commands::VERSION = '0.324';
use App::Cmd::Command;
BEGIN { our @ISA = 'App::Cmd::Command' };
# ABSTRACT: list the application's commands
#pod =head1 DESCRIPTION
#pod
#pod This command plugin implements a "commands" command. This command will list
#pod all of an App::Cmd's commands and their abstracts.
#pod
#pod =method execute
#pod
#pod This is the command's primary method and raison d'etre. It prints the
#pod application's usage text (if any) followed by a sorted listing of the
#pod application's commands and their abstracts.
#pod
#pod The commands are printed in sorted groups (created by C<sort_commands>); each
#pod group is set off by blank lines.
#pod
#pod =cut
sub execute {
my ($self, $opt, $args) = @_;
my $target = $opt->stderr ? *STDERR : *STDOUT;
local $@;
eval { print { $target } $self->app->_usage_text . "\n" };
print { $target } "Available commands:\n\n";
my @primary_commands =
grep { $_ ne 'version' }
map { ($_->command_names)[0] }
$self->app->command_plugins;
my @cmd_groups = $self->sort_commands(@primary_commands);
my $fmt_width = 0;
for (@primary_commands) { $fmt_width = length if length > $fmt_width }
$fmt_width += 2; # pretty
foreach my $cmd_set (@cmd_groups) {
for my $command (@$cmd_set) {
my $abstract = $self->app->plugin_for($command)->abstract;
printf { $target } "%${fmt_width}s: %s\n", $command, $abstract;
}
print { $target } "\n";
}
}
#pod =method C<sort_commands>
#pod
#pod my @sorted = $cmd->sort_commands(@unsorted);
#pod
#pod This method orders the list of commands into sets which it returns as a list of
#pod arrayrefs.
#pod
#pod By default, the first group is for the "help" and "commands" commands, and all
#pod other commands are in the second group.
#pod
#pod =cut
sub sort_commands {
my ($self, @commands) = @_;
my $float = qr/^(?:help|commands)$/;
my @head = sort grep { $_ =~ $float } @commands;
my @tail = sort grep { $_ !~ $float } @commands;
return (\@head, \@tail);
}
sub opt_spec {
return (
[ 'stderr' => 'hidden' ],
);
}
sub description {
"This command will list all of commands available and their abstracts.\n";
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Cmd::Command::commands - list the application's commands
=head1 VERSION
version 0.324
=head1 DESCRIPTION
This command plugin implements a "commands" command. This command will list
all of an App::Cmd's commands and their abstracts.
=head1 METHODS
=head2 execute
This is the command's primary method and raison d'etre. It prints the
application's usage text (if any) followed by a sorted listing of the
application's commands and their abstracts.
The commands are printed in sorted groups (created by C<sort_commands>); each
group is set off by blank lines.
=head2 C<sort_commands>
my @sorted = $cmd->sort_commands(@unsorted);
This method orders the list of commands into sets which it returns as a list of
arrayrefs.
By default, the first group is for the "help" and "commands" commands, and all
other commands are in the second group.
=head1 AUTHOR
Ricardo Signes <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|