line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TemplateCMD::Command::Help; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2008-03-26 13:58:38 |
4
|
|
|
|
|
|
|
# Create by: ivanw |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1775
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
53
|
|
10
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
11
|
2
|
|
|
2
|
|
402
|
use version; |
|
2
|
|
|
|
|
1591
|
|
|
2
|
|
|
|
|
12
|
|
12
|
2
|
|
|
2
|
|
117
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
141
|
|
13
|
2
|
|
|
2
|
|
536
|
use List::MoreUtils qw/uniq/; |
|
2
|
|
|
|
|
11337
|
|
|
2
|
|
|
|
|
15
|
|
14
|
2
|
|
|
2
|
|
2072
|
use Data::Dumper qw/Dumper/; |
|
2
|
|
|
|
|
5851
|
|
|
2
|
|
|
|
|
106
|
|
15
|
2
|
|
|
2
|
|
461
|
use English qw/ -no_match_vars /; |
|
2
|
|
|
|
|
1493
|
|
|
2
|
|
|
|
|
13
|
|
16
|
2
|
|
|
2
|
|
649
|
use base qw/App::TemplateCMD::Command/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
641
|
|
17
|
2
|
|
|
2
|
|
18
|
use File::Glob; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1175
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = version->new('0.6.11'); |
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw//; |
21
|
|
|
|
|
|
|
our %EXPORT_TAGS = (); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub process { |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
0
|
1
|
|
my ( $self, $cmd, %option ) = @_; |
26
|
0
|
|
|
|
|
|
my $out; |
27
|
0
|
|
|
|
|
|
my $config = $cmd->config; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $command = shift @{ $option{files} }; |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $module; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ($command) { |
33
|
0
|
|
|
|
|
|
$module = eval { $cmd->load_cmd($command) }; |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
0
|
0
|
0
|
|
|
|
if ($module) { |
|
|
0
|
0
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
$out = $module->help() if $module->can('help'); |
37
|
0
|
0
|
|
|
|
|
$out .= $module->HELP() if $module->can('HELP'); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
0
|
|
|
|
$out ||= "No help found for $command\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ( $command && $self->can($command) && $command ne 'process' ) { |
42
|
0
|
|
|
|
|
|
$out = $self->$command(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @cmds = sort $self->commands(); |
47
|
0
|
|
|
|
|
|
my $cmds = ''; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
for my $name (@cmds) { |
50
|
0
|
|
|
|
|
|
my @aliases = sort {length $b <=> length $a} grep { $config->{aliases}{$_} eq lc $name } keys %{ $config->{aliases} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$cmds .= ' ' . lc $name; |
52
|
0
|
0
|
|
|
|
|
$cmds .= ' (' . ( join ', ', @aliases ) . ')' if @aliases; |
53
|
0
|
|
|
|
|
|
$cmds .= "\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$out = <<"OUT"; |
57
|
|
|
|
|
|
|
usage: templatecmd [options] [args] |
58
|
|
|
|
|
|
|
App::TemplateCMD command-line template system, version $App::TemplateCMD::VERSION. |
59
|
|
|
|
|
|
|
Type 'templatecmd help ' for help on a specific command. |
60
|
|
|
|
|
|
|
Type 'templatecmd --version' to see the program version. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Available commands: |
63
|
|
|
|
|
|
|
$cmds |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
App::TemplateCMD is a command-line interface to Perl's Template Toolkit (TT) templating |
66
|
|
|
|
|
|
|
system. For help with creating TT templates see 'perldoc Template' |
67
|
|
|
|
|
|
|
OUT |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return $out; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub commands { |
74
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my @cmds; |
77
|
0
|
|
|
|
|
|
my $cmd_path = 'App/TemplateCMD/Command'; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
for my $path (@INC) { |
80
|
0
|
|
|
|
|
|
my @modules = glob("$path/$cmd_path/*.pm"); |
81
|
0
|
|
|
|
|
|
for my $module (@modules) { |
82
|
0
|
|
|
|
|
|
$module =~ s{^ $path / $cmd_path / (.*) [.]pm $}{$1}xms; |
83
|
0
|
|
|
|
|
|
push @cmds, $module; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return uniq @cmds; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub help { |
91
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return <<"HELP"; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
HELP |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub templates { |
99
|
0
|
|
|
0
|
1
|
|
return <<"HELP"; |
100
|
|
|
|
|
|
|
Templates |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
App::TemplateCMD uses Template Toolkit as its templateing engine the individual |
103
|
|
|
|
|
|
|
templates can be found in the directories specified by the "$0 config -v" |
104
|
|
|
|
|
|
|
command. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
When the templates are passed any --args value specified on the command line |
107
|
|
|
|
|
|
|
is passed to the template along with values specified by the config file(s) |
108
|
|
|
|
|
|
|
found. Certain values are over ridden by the program each time it is run |
109
|
|
|
|
|
|
|
such as the date and time values. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
... |
112
|
|
|
|
|
|
|
HELP |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |