| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
12
|
|
|
12
|
|
7372
|
use strict; |
|
|
12
|
|
|
|
|
28
|
|
|
|
12
|
|
|
|
|
366
|
|
|
2
|
12
|
|
|
12
|
|
64
|
use warnings; |
|
|
12
|
|
|
|
|
26
|
|
|
|
12
|
|
|
|
|
464
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::Cmd::Command::help 0.335; |
|
5
|
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
156
|
use App::Cmd::Command; |
|
|
12
|
|
|
|
|
28
|
|
|
|
12
|
|
|
|
|
563
|
|
|
7
|
12
|
|
|
12
|
|
3515
|
BEGIN { our @ISA = 'App::Cmd::Command'; } |
|
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 method |
|
23
|
|
|
|
|
|
|
#pod * The C method |
|
24
|
|
|
|
|
|
|
#pod * The C data structure |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod The C method provides the opening usage line, following the |
|
27
|
|
|
|
|
|
|
#pod specification described in L. In some cases, |
|
28
|
|
|
|
|
|
|
#pod the default C in L 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 data structure is used with L |
|
33
|
|
|
|
|
|
|
#pod to generate the description of the options. |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod Subcommand classes should override the C 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
|
|
|
|
|
|
|
|
|
75
|
5
|
|
|
5
|
1
|
36
|
sub usage_desc { '%c help [subcommand]' } |
|
76
|
|
|
|
|
|
|
|
|
77
|
31
|
|
|
31
|
1
|
107
|
sub command_names { qw/help --help -h -?/ } |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub execute { |
|
80
|
4
|
|
|
4
|
1
|
11
|
my ($self, $opts, $args) = @_; |
|
81
|
|
|
|
|
|
|
|
|
82
|
4
|
50
|
|
|
|
15
|
if (!@$args) { |
|
83
|
0
|
|
|
|
|
0
|
print $self->app->usage->text . "\n"; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
print "Available commands:\n\n"; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
$self->app->execute_command( $self->app->_prepare_command("commands") ); |
|
88
|
|
|
|
|
|
|
} else { |
|
89
|
4
|
|
|
|
|
18
|
my ($cmd, $opt, $args) = $self->app->prepare_command(@$args); |
|
90
|
|
|
|
|
|
|
|
|
91
|
4
|
|
|
|
|
12
|
local $@; |
|
92
|
4
|
|
|
|
|
32
|
my $desc = $cmd->description; |
|
93
|
4
|
100
|
|
|
|
27
|
$desc = "\n$desc" if length $desc; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $ut = join "\n", |
|
96
|
4
|
|
|
|
|
46
|
eval { $cmd->usage->leader_text }, |
|
97
|
|
|
|
|
|
|
$desc, |
|
98
|
4
|
|
|
|
|
14
|
eval { $cmd->usage->option_text }; |
|
|
4
|
|
|
|
|
60
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
296
|
print "$ut\n"; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |