← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/local/share/perl/5.18.2/App/Cmd/Command/help.pm
StatementsExecuted 10 statements in 270µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs24µsModule::Runtime::::BEGIN@1.12 Module::Runtime::BEGIN@1.12
11112µs16µsModule::Runtime::::BEGIN@2.13 Module::Runtime::BEGIN@2.13
1119µs9µsApp::Cmd::Command::help::::BEGIN@7App::Cmd::Command::help::BEGIN@7
1114µs4µsApp::Cmd::Command::help::::BEGIN@6App::Cmd::Command::help::BEGIN@6
1112µs2µsApp::Cmd::Command::help::::command_namesApp::Cmd::Command::help::command_names
0000s0sApp::Cmd::Command::help::::executeApp::Cmd::Command::help::execute
0000s0sApp::Cmd::Command::help::::usage_descApp::Cmd::Command::help::usage_desc
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1222µs236µs
# spent 24µs (12+12) within Module::Runtime::BEGIN@1.12 which was called: # once (12µs+12µs) by Module::Runtime::require_module at line 1
use strict;
# spent 24µs making 1 call to Module::Runtime::BEGIN@1.12 # spent 12µs making 1 call to strict::import
2234µs221µs
# spent 16µs (12+5) within Module::Runtime::BEGIN@2.13 which was called: # once (12µs+5µs) by Module::Runtime::require_module at line 2
use warnings;
# spent 16µs making 1 call to Module::Runtime::BEGIN@2.13 # spent 5µs making 1 call to warnings::import
3
4package App::Cmd::Command::help;
51400ns$App::Cmd::Command::help::VERSION = '0.330';
6226µs14µs
# spent 4µs within App::Cmd::Command::help::BEGIN@6 which was called: # once (4µs+0s) by Module::Runtime::require_module at line 6
use App::Cmd::Command;
# spent 4µs making 1 call to App::Cmd::Command::help::BEGIN@6
71182µs19µs
# spent 9µs within App::Cmd::Command::help::BEGIN@7 which was called: # once (9µs+0s) by Module::Runtime::require_module at line 7
BEGIN { our @ISA = 'App::Cmd::Command'; }
# spent 9µs making 1 call to App::Cmd::Command::help::BEGIN@7
8
9# ABSTRACT: display a command's help screen
10
11#pod =head1 DESCRIPTION
12#pod
13#pod This command will either list all of the application commands and their
14#pod abstracts, or display the usage screen for a subcommand with its
15#pod description.
16#pod
17#pod =head1 USAGE
18#pod
19#pod The help text is generated from three sources:
20#pod
21#pod =for :list
22#pod * The C<usage_desc> method
23#pod * The C<description> method
24#pod * The C<opt_spec> data structure
25#pod
26#pod The C<usage_desc> method provides the opening usage line, following the
27#pod specification described in L<Getopt::Long::Descriptive>. In some cases,
28#pod the default C<usage_desc> in L<App::Cmd::Command> may be sufficient and
29#pod you will only need to override it to provide additional command line
30#pod usage information.
31#pod
32#pod The C<opt_spec> data structure is used with L<Getopt::Long::Descriptive>
33#pod to generate the description of the options.
34#pod
35#pod Subcommand classes should override the C<discription> method to provide
36#pod additional information that is prepended before the option descriptions.
37#pod
38#pod For example, consider the following subcommand module:
39#pod
40#pod package YourApp::Command::initialize;
41#pod
42#pod # This is the default from App::Cmd::Command
43#pod sub usage_desc {
44#pod my ($self) = @_;
45#pod my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o"
46#pod return "$desc [DIRECTORY]";
47#pod }
48#pod
49#pod sub description {
50#pod return "The initialize command prepares the application...";
51#pod }
52#pod
53#pod sub opt_spec {
54#pod return (
55#pod [ "skip-refs|R", "skip reference checks during init", ],
56#pod [ "values|v=s@", "starting values", { default => [ 0, 1, 3 ] } ],
57#pod );
58#pod }
59#pod
60#pod ...
61#pod
62#pod That module would generate help output like this:
63#pod
64#pod $ yourapp help initialize
65#pod yourapp initialize [-Rv] [long options...] [DIRECTORY]
66#pod
67#pod The initialize command prepares the application...
68#pod
69#pod --help This usage screen
70#pod -R --skip-refs skip reference checks during init
71#pod -v --values starting values
72#pod
73#pod =cut
74
75sub usage_desc { '%c help [subcommand]' }
76
7713µs
# spent 2µs within App::Cmd::Command::help::command_names which was called: # once (2µs+0s) by App::Cmd::_load_default_plugin at line 288 of App/Cmd.pm
sub command_names { qw/help --help -h -?/ }
78
79sub execute {
80 my ($self, $opts, $args) = @_;
81
82 if (!@$args) {
83 print $self->app->usage->text . "\n";
84
85 print "Available commands:\n\n";
86
87 $self->app->execute_command( $self->app->_prepare_command("commands") );
88 } else {
89 my ($cmd, $opt, $args) = $self->app->prepare_command(@$args);
90
91 local $@;
92 my $desc = $cmd->description;
93 $desc = "\n$desc" if length $desc;
94
95 my $ut = join "\n",
96 eval { $cmd->usage->leader_text },
97 $desc,
98 eval { $cmd->usage->option_text };
99
100 print "$ut\n";
101 }
102}
103
10412µs1;
105
106__END__