| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SweetPea::Cli; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
31446
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
48
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
16
|
|
|
|
1
|
|
|
|
|
40
|
|
|
6
|
1
|
|
|
1
|
|
2806
|
use App::Rad; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
1
|
|
|
1
|
|
1963
|
use SweetPea::Application 0.022; |
|
|
1
|
|
|
|
|
72345
|
|
|
|
1
|
|
|
|
|
81
|
|
|
8
|
1
|
|
|
1
|
|
1978
|
use SweetPea::Cli::Util; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
9
|
1
|
|
|
1
|
|
1478
|
use SweetPea::Cli::Make; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
37
|
|
|
10
|
1
|
|
|
1
|
|
5357
|
use SweetPea::Cli::Data; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
11
|
1
|
|
|
1
|
|
11
|
use SweetPea::Cli::Help; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
20
|
|
|
12
|
1
|
|
|
1
|
|
2127
|
use SweetPea::Cli::Tool; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
39
|
|
|
13
|
1
|
|
|
1
|
|
1825
|
use SweetPea::Cli::Mvc; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
42
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
|
16
|
1
|
|
|
1
|
|
6
|
use Exporter(); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use vars qw( @ISA @EXPORT @EXPORT_OK ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
83
|
|
|
18
|
1
|
|
|
1
|
|
21
|
@ISA = qw( Exporter ); |
|
19
|
1
|
|
|
|
|
724
|
@EXPORT = qw(shell); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
SweetPea::Cli - Rapid Application Development for SweetPea Packages |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 VERSION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Version 0.08 |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
... from the command-line |
|
37
|
|
|
|
|
|
|
sweetpea |
|
38
|
|
|
|
|
|
|
or |
|
39
|
|
|
|
|
|
|
perl -MSweetPea::Cli -e shell |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DOCUMENTATION |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * Detailed Documentation |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
L |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * Live Documentation |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=back |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub shell { |
|
59
|
0
|
|
|
0
|
0
|
|
App::Rad->shell({ |
|
60
|
|
|
|
|
|
|
title => [], |
|
61
|
|
|
|
|
|
|
prompt => 'sweetpea:', |
|
62
|
|
|
|
|
|
|
autocomp => 1, |
|
63
|
|
|
|
|
|
|
abbrev => 1, |
|
64
|
|
|
|
|
|
|
ignorecase => 0, |
|
65
|
|
|
|
|
|
|
history => 1, # or 'path/to/histfile.txt' |
|
66
|
|
|
|
|
|
|
}); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub main::setup { |
|
70
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
71
|
0
|
|
|
|
|
|
$c->stash->{commands} = $c->{_commands}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $m = [ |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
|
|
|
|
|
|
name => 'help', |
|
76
|
|
|
|
|
|
|
code => sub { |
|
77
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
78
|
0
|
|
|
|
|
|
my $u = SweetPea::Cli::Util->new; |
|
79
|
0
|
|
|
|
|
|
my $h = SweetPea::Cli::Help->new; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# display help document for a specific function |
|
82
|
0
|
0
|
|
|
|
|
if (defined $c->argv->[0]) { |
|
83
|
0
|
0
|
|
|
|
|
if (defined $c->{_commands}->{$c->argv->[0]}) { |
|
84
|
0
|
|
|
|
|
|
return $h->display($c->argv->[0], $c); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $u->template('menus/commands.tt', $c); |
|
89
|
|
|
|
|
|
|
}, |
|
90
|
|
|
|
|
|
|
help => 'display available commands.' |
|
91
|
|
|
|
|
|
|
}, |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
|
|
|
|
|
|
name => 'menu', |
|
94
|
|
|
|
|
|
|
code => sub { |
|
95
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
96
|
0
|
|
|
|
|
|
my $u = SweetPea::Cli::Util->new; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $u->template('menus/master.tt', $c); |
|
99
|
|
|
|
|
|
|
}, |
|
100
|
0
|
|
|
|
|
|
help => 'display main menu.' |
|
101
|
|
|
|
|
|
|
}, |
|
102
|
|
|
|
|
|
|
]; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$c->register( $_->{name}, $_->{code}, $_->{help} ) |
|
105
|
0
|
|
|
|
|
|
foreach @{$m}; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# register make commands |
|
108
|
0
|
|
|
|
|
|
foreach my $cmd ( @{SweetPea::Cli::Make->new($c)->{commands}} ) { |
|
|
0
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $n = $c->register($cmd->{name}, $cmd->{code}, $cmd->{help}); |
|
110
|
0
|
|
|
|
|
|
$c->{_commands}->{$n}->{args} = $cmd->{args}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# register data commands |
|
114
|
0
|
|
|
|
|
|
foreach my $cmd ( @{SweetPea::Cli::Data->new($c)->{commands}} ) { |
|
|
0
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $n = $c->register($cmd->{name}, $cmd->{code}, $cmd->{help}); |
|
116
|
0
|
|
|
|
|
|
$c->{_commands}->{$n}->{args} = $cmd->{args}; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# register toolbox commands |
|
120
|
|
|
|
|
|
|
#foreach my $cmd ( @{SweetPea::Cli::Tool->new($c)->{commands}} ) { |
|
121
|
|
|
|
|
|
|
# my $n = $c->register($cmd->{name}, $cmd->{code}, $cmd->{help}); |
|
122
|
|
|
|
|
|
|
# $c->{_commands}->{$n}->{args} = $cmd->{args}; |
|
123
|
|
|
|
|
|
|
#} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# register MVC commands |
|
126
|
0
|
|
|
|
|
|
foreach my $cmd ( @{SweetPea::Cli::Mvc->new($c)->{commands}} ) { |
|
|
0
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $n = $c->register($cmd->{name}, $cmd->{code}, $cmd->{help}); |
|
128
|
0
|
|
|
|
|
|
$c->{_commands}->{$n}->{args} = $cmd->{args}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$c->{'_functions'}->{'invalid'} = sub { |
|
132
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
133
|
0
|
|
|
|
|
|
my $u = SweetPea::Cli::Util->new; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
return $u->template('misc/error_string.tt', $c); |
|
136
|
0
|
|
|
|
|
|
}; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub main::pre_process { |
|
140
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
#sub App::Rad::error { |
|
145
|
|
|
|
|
|
|
# my $c = shift; |
|
146
|
|
|
|
|
|
|
# my $e = shift; |
|
147
|
|
|
|
|
|
|
# |
|
148
|
|
|
|
|
|
|
# if ( $c->{state} eq "shell" ) { |
|
149
|
|
|
|
|
|
|
# my $u = SweetPea::Cli::Util->new; |
|
150
|
|
|
|
|
|
|
# $e =~ s/(^[\r\n]+|[\r\n]+$)//g; |
|
151
|
|
|
|
|
|
|
# $c->stash->{errors} = ["$e\n","\n"]; |
|
152
|
|
|
|
|
|
|
# return $u->template('misc/error_string.tt', $c); |
|
153
|
|
|
|
|
|
|
# } |
|
154
|
|
|
|
|
|
|
# else { |
|
155
|
|
|
|
|
|
|
# Carp::croak "$e----\n"; |
|
156
|
|
|
|
|
|
|
# } |
|
157
|
|
|
|
|
|
|
#} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Al Newkirk, C<< >> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 BUGS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
166
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
167
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SUPPORT |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
perldoc SweetPea::Cli |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
You can also look for information at: |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=over 4 |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * Search CPAN |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Al Newkirk |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Copyright 2009 Al Newkirk, all rights reserved. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
207
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
1; # End of SweetPea::Cli |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
__DATA__ |