blib/lib/Hailo/Command.pm

filter: Statementstmt 94.4% 152 / 161 Branchbran 78.5% 33 / 42 Conditioncond 70.9% 44 / 62 MC/DCmcdc 22.2% 6 / 27 Subroutinesub 95.8% 23 / 24 Podpod n/a totaltotal 81.6% 258 / 316 CC 44 SCAR 24.9
CC
44
Cov
86%
run
25.9
__ANON__
12.1
train_progress
6.4
CRAP 12.0
« blib/lib/Hailo/Tokenizer/Words.pm ↑ Summary blib/lib/Hailo/Storage/Schema.pm »
1 package Hailo::Command;
2 13 our $AUTHORITY = 'cpan:AVAR';
3 13 $Hailo::Command::VERSION = '0.74';
4 13 ▶use v5.28.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use MooseX::Types::Moose ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use MooseX::Getopt;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 extends 'Hailo';
12  
13 13 with 'MooseX::Getopt::Dashes';
14  
15 ## Our internal Getopts method that Hailo.pm doesn't care about.
16  
17 13 has help_flag => (
18 traits => [ qw/ Getopt / ],
19 cmd_aliases => 'h',
20 cmd_flag => 'help',
21 isa => Bool,
22 is => 'ro',
23 default => 0,
24 documentation => "You're soaking it in",
25 );
26  
27 13 has _go_version => (
28 traits => [ qw/ Getopt / ],
29 cmd_aliases => 'v',
30 cmd_flag => 'version',
31 documentation => 'Print version and exit',
32 isa => Bool,
33 is => 'ro',
34 );
35  
36 13 has _go_examples => (
37 traits => [ qw/ Getopt / ],
38 cmd_flag => 'examples',
39 documentation => 'Print examples along with the help message',
40 isa => Bool,
41 is => 'ro',
42 );
43  
44 has _go_progress => (
45 traits => [ qw/ Getopt / ],
46 cmd_aliases => 'p',
47 cmd_flag => 'progress',
48 documentation => 'Display progress during the import',
49 isa => Bool,
50 is => 'ro',
51 default => sub {
52 12 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
53 12 $self->_is_interactive();
54 },
55 13 );
56  
57 13 has _go_learn => (
58 traits => [ qw/ Getopt / ],
59 cmd_aliases => "l",
60 cmd_flag => "learn",
61 documentation => "Learn from STRING",
62 isa => Str,
63 is => "ro",
64 );
65  
66 13 has _go_learn_reply => (
67 traits => [ qw/ Getopt / ],
68 cmd_aliases => "L",
69 cmd_flag => "learn-reply",
70 documentation => "Learn from STRING and reply to it",
71 isa => Str,
72 is => "ro",
73 );
74  
75 13 has _go_train => (
76 traits => [ qw/ Getopt / ],
77 cmd_aliases => "t",
78 cmd_flag => "train",
79 documentation => "Learn from all the lines in FILE, use - for STDIN",
80 isa => Str,
81 is => "ro",
82 );
83  
84 13 has _go_train_fast => (
85 traits => [ qw/ Getopt / ],
86 cmd_aliases => "f",
87 cmd_flag => "train-fast",
88 documentation => "Train with aggressive caching (memory-hungry!)",
89 isa => Str,
90 is => "ro",
91 );
92  
93 13 has _go_reply => (
94 traits => [ qw/ Getopt / ],
95 cmd_aliases => "r",
96 cmd_flag => "reply",
97 documentation => "Reply to STRING",
98 isa => Str,
99 is => "ro",
100 );
101  
102 13 has _go_random_reply => (
103 traits => [ qw/ Getopt / ],
104 cmd_aliases => "R",
105 cmd_flag => "random-reply",
106 documentation => "Like --reply but takes no STRING; Babble at random",
107 isa => Bool,
108 is => "ro",
109 );
110  
111 13 has _go_stats => (
112 traits => [ qw/ Getopt / ],
113 cmd_aliases => "s",
114 cmd_flag => "stats",
115 documentation => "Print statistics about the brain",
116 isa => Bool,
117 is => "ro",
118 );
119  
120 ## Things we have to pass to Hailo.pm via triggers when they're set
121  
122 has _go_autosave => (
123 traits => [ qw/ Getopt / ],
124 cmd_aliases => 'a',
125 cmd_flag => 'autosave',
126 documentation => 'Save the brain on exit (on by default)',
127 isa => Bool,
128 is => 'rw',
129 trigger => sub {
130 1 ▶ my ($self, $bool) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
131 1 $self->save_on_exit($bool);
132 },
133 13 );
134  
135 has _go_order => (
136 traits => [ qw/ Getopt / ],
137 cmd_aliases => "o",
138 cmd_flag => "order",
139 documentation => "Markov order; How deep the rabbit hole goes",
140 isa => Int,
141 is => "rw",
142 trigger => sub {
143 2 ▶ my ($self, $order) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
144 2 $self->order($order);
145 },
146 13 );
147  
148 has _go_brain => (
149 traits => [ qw/ Getopt / ],
150 cmd_aliases => "b",
151 cmd_flag => "brain",
152 documentation => "Load/save brain to/from FILE",
153 isa => Str,
154 is => "ro",
155 trigger => sub {
156 13 ▶ my ($self, $brain) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
157 13 $self->brain($brain);
158 },
159 13 );
160  
161 # working classes
162 has _go_engine_class => (
163 traits => [ qw/ Getopt / ],
164 cmd_aliases => "E",
165 cmd_flag => "engine",
166 isa => Str,
167 is => "rw",
168 documentation => "Use engine CLASS",
169 trigger => sub {
170 0 ▶ my ($self, $class) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
171 0 $self->engine_class($class);
172 },
173 13 );
174  
175 has _go_storage_class => (
176 traits => [ qw/ Getopt / ],
177 cmd_aliases => "S",
178 cmd_flag => "storage",
179 isa => Str,
180 is => "rw",
181 documentation => "Use storage CLASS",
182 trigger => sub {
183 5 ▶ my ($self, $class) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
184 5 $self->storage_class($class);
185 },
186 13 );
187  
188 has _go_tokenizer_class => (
189 traits => [ qw/ Getopt / ],
190 cmd_aliases => "T",
191 cmd_flag => "tokenizer",
192 isa => Str,
193 is => "rw",
194 documentation => "Use tokenizer CLASS",
195 trigger => sub {
196 1 ▶ my ($self, $class) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
197 1 $self->tokenizer_class($class);
198 },
199 13 );
200  
201 has _go_ui_class => (
202 traits => [ qw/ Getopt / ],
203 cmd_aliases => "u",
204 cmd_flag => "ui",
205 isa => Str,
206 is => "rw",
207 documentation => "Use UI CLASS",
208 trigger => sub {
209 1 ▶ my ($self, $class) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
210 1 $self->ui_class($class);
211 },
212 13 );
213  
214 # Stop Hailo from polluting our command-line interface
215 13 for (qw/ save_on_exit order brain /, map { qq[${_}_class] } qw/ engine storage tokenizer ui /) {
216 91 has "+$_" => (
217 traits => [ qw/ NoGetopt / ],
218 );
219 }
220  
221 # Check validity of options
222 before run => sub {
223 20 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=11 SCAR=24.9
224  
225 20 ▶ if (not $self->_storage->ready and
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_storage->ready and defined $self->_go_reply || defined $self->_go_train || defined $self->_go_train_fast || defined $self->_go_stats || defined $self->_go_learn || defined $self->_go_learn_reply || defined $self->_go_random_reply) 1 16 17
Condition80%17/21
not $self->_storage->ready and defined $self->_go_reply || defined $self->_go_train || defined $self->_go_train_fast || defined $self->_go_stats || defined $self->_go_learn || defined $self->_go_learn_reply || defined $self->_go_random_reply
!ll&&!rl&&r
1280
defined $self->_go_reply or defined $self->_go_train or defined $self->_go_train_fast or defined $self->_go_stats or defined $self->_go_learn or defined $self->_go_learn_reply or defined $self->_go_random_reply
l!l&&r!l&&!r
404
defined $self->_go_reply or defined $self->_go_train or defined $self->_go_train_fast or defined $self->_go_stats or defined $self->_go_learn or defined $self->_go_learn_reply
l!l&&r!l&&!r
314
defined $self->_go_reply or defined $self->_go_train or defined $self->_go_train_fast or defined $self->_go_stats or defined $self->_go_learn
l!l&&r!l&&!r
215
defined $self->_go_reply or defined $self->_go_train or defined $self->_go_train_fast or defined $self->_go_stats
l!l&&r!l&&!r
206
defined $self->_go_reply or defined $self->_go_train or defined $self->_go_train_fast
l!l&&r!l&&!r
206
defined $self->_go_reply or defined $self->_go_train
l!l&&r!l&&!r
116
MC/DC25%2/8
not $self->_storage->ready and defined $self->_go_reply || defined $self->_go_train || defined $self->_go_train_fast || defined $self->_go_stats || defined $self->_go_learn || defined $self->_go_learn_reply || defined $self->_go_random_reply
not $self->_storage->ready defined $self->_go_reply defined $self->_go_train defined $self->_go_train_fast defined $self->_go_stats defined $self->_go_learn defined $self->_go_learn_reply defined $self->_go_random_reply
Truth table33%3/9
not(A) and B or C or D or E or F or G or H
A= not $self->_storage->readyB= defined $self->_go_replyC= defined $self->_go_trainD= defined $self->_go_train_fastE= defined $self->_go_statsF= defined $self->_go_learnG= defined $self->_go_learn_replyH= defined $self->_go_random_reply
ABCDEFGHresult
0XXXXXXX0
100000000
11XXXXXX1
101XXXXX1
1001XXXX1
10001XXX1
100001XX1
1000001X1
100000011
226 (defined $self->_go_reply or
227 defined $self->_go_train or
228 defined $self->_go_train_fast or
229 defined $self->_go_stats or
230 defined $self->_go_learn or
231 defined $self->_go_learn_reply or
232 defined $self->_go_random_reply)) {
233 # TODO: Make this spew out the --help reply just like hailo
234 # with invalid options does usually, but only if run via
235 # ->new_with_options
236 4 die "To reply/train/learn/stat you must specify options to initialize your storage backend\n";
237 }
238  
239 16 ▶ if (defined $self->_go_train and defined $self->_go_train_fast) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_go_train and defined $self->_go_train_fast) 0 16 16
Condition66%2/3
defined $self->_go_train and defined $self->_go_train_fast
!ll&&!rl&&r
790
MC/DC0%0/2
defined $self->_go_train and defined $self->_go_train_fast
defined $self->_go_train defined $self->_go_train_fast
Truth table66%2/3
A and B
A= defined $self->_go_trainB= defined $self->_go_train_fast
ABresult
0X0
100
111
240 0 die "You can only specify one of --train and --train-fast\n";
241 }
242  
243 16 return;
244 13 };
245  
246 sub run {
247 16 ▶ my ($self) = @_;
Subroutine run: called CC=22 SCAR=32.5
248  
249 16 ▶ if ($self->_go_version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_go_version) 3 13 16
250 # Munging strictness because we don't have a version from a
251 # Git checkout. Dist::Zilla provides it.
252 13 ▶ no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
253 3 ▶ my $version = $VERSION // 'dev-git';
Condition50%1/2
$VERSION // "dev-git"
l!l
30
MC/DC0%0/1
$VERSION // "dev-git"
$VERSION
Truth table50%1/2
A
A= $VERSION
Aresult
11
00
254  
255 3 say "hailo $version";
256 3 return;
257 }
258  
259 13 ▶ if ($self->_is_interactive() and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn and not defined $self->_go_reply and not defined $self->_go_learn_reply and not defined $self->_go_stats and not defined $self->_go_random_reply) 1 12 13
Condition66%16/24
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn and not defined $self->_go_reply and not defined $self->_go_learn_reply and not defined $self->_go_stats and not defined $self->_go_random_reply
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn and not defined $self->_go_reply and not defined $self->_go_learn_reply and not defined $self->_go_stats
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn and not defined $self->_go_reply and not defined $self->_go_learn_reply
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn and not defined $self->_go_reply
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train
!ll&&!rl&&r
1201
$self->_is_interactive and $self->_storage->ready
!ll&&!rl&&r
1201
MC/DC11%1/9
$self->_is_interactive and $self->_storage->ready and not defined $self->_go_train and not defined $self->_go_train_fast and not defined $self->_go_learn and not defined $self->_go_reply and not defined $self->_go_learn_reply and not defined $self->_go_stats and not defined $self->_go_random_reply
$self->_is_interactive $self->_storage->ready not defined $self->_go_train not defined $self->_go_train_fast not defined $self->_go_learn not defined $self->_go_reply not defined $self->_go_learn_reply not defined $self->_go_stats not defined $self->_go_random_reply
Truth table20%2/10
A and B and not(C) and not(D) and not(E) and not(F) and not(G) and not(H) and not(I)
A= $self->_is_interactiveB= $self->_storage->readyC= not defined $self->_go_trainD= not defined $self->_go_train_fastE= not defined $self->_go_learnF= not defined $self->_go_replyG= not defined $self->_go_learn_replyH= not defined $self->_go_statsI= not defined $self->_go_random_reply
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
110XXXXXX0
1110XXXXX0
11110XXXX0
111110XXX0
1111110XX0
11111110X0
1111111100
1111111111
260 $self->_storage->ready and
261 not defined $self->_go_train and
262 not defined $self->_go_train_fast and
263 not defined $self->_go_learn and
264 not defined $self->_go_reply and
265 not defined $self->_go_learn_reply and
266 not defined $self->_go_stats and
267 not defined $self->_go_random_reply) {
268 1 $self->_ui->run($self);
269 }
270  
271 12 ▶ $self->train($self->_go_train) if defined $self->_go_train;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->_go_train 9 3 12
272 12 ▶ $self->train($self->_go_train_fast, 1) if defined $self->_go_train_fast;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->_go_train_fast 0 12 12
273 12 ▶ $self->learn($self->_go_learn) if defined $self->_go_learn;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->_go_learn 0 12 12
274  
275 12 ▶ if (defined $self->_go_learn_reply) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_go_learn_reply) 2 10 12
276 2 my $answer = $self->learn_reply($self->_go_learn_reply);
277 2 ▶ say $answer // "I don't know enough to answer you yet.";
Condition100%2/2
$answer // "I don't know enough to answer you yet."
l!l
11
MC/DC100%1/1
$answer // "I don't know enough to answer you yet."
$answer
Truth table100%2/2
A
A= $answer
Aresult
11
00
278 }
279  
280 12 ▶ if (defined $self->_go_random_reply) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->_go_random_reply) { } 0 12 12
elsif (defined $self->_go_reply) { } 2 10 12
281 0 my $answer = $self->reply();
282 0 ▶ say $answer // "I don't know enough to answer you yet.";
Condition0%0/2
$answer // "I don't know enough to answer you yet."
l!l
00
MC/DC0%0/1
$answer // "I don't know enough to answer you yet."
$answer
Truth table0%0/2
A
A= $answer
Aresult
11
00
283 }
284 elsif (defined $self->_go_reply) {
285 2 my $answer = $self->reply($self->_go_reply);
286 2 ▶ say $answer // "I don't know enough to answer you yet.";
Condition100%2/2
$answer // "I don't know enough to answer you yet."
l!l
11
MC/DC100%1/1
$answer // "I don't know enough to answer you yet."
$answer
Truth table100%2/2
A
A= $answer
Aresult
11
00
287 }
288  
289 12 ▶ if ($self->_go_stats) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_go_stats) 5 7 12
290 5 my ($tok, $ex, $prev, $next) = $self->stats();
291 5 my $order = $self->_storage->order;
292 5 say "Tokens: $tok";
293 5 say "Expression length: $order tokens";
294 5 say "Expressions: $ex";
295 5 say "Links to preceding tokens: $prev";
296 5 say "Links to following tokens: $next";
297 }
298  
299 12 return;
300 }
301  
302 override _train_fh => sub {
303 10 ▶ my ($self, $fh, $fast, $filename) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
304  
305 10 ▶ if ($self->_go_progress and $self->_is_interactive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_go_progress and $self->_is_interactive) { } 1 9 10
Condition66%2/3
$self->_go_progress and $self->_is_interactive
!ll&&!rl&&r
901
MC/DC50%1/2
$self->_go_progress and $self->_is_interactive
$self->_go_progress $self->_is_interactive
Truth table66%2/3
A and B
A= $self->_go_progressB= $self->_is_interactive
ABresult
0X0
100
111
306 1 $self->train_progress($fh, $fast, $filename);
307 } else {
308 9 super();
309 }
310 13 };
311  
312 before train_progress => sub {
313 1 ▶ require Term::Sk;
Subroutine __ANON__: called CC=1 SCAR=0.0
314 1 require File::CountLines;
315 1 File::CountLines->import('count_lines');
316 1 require Time::HiRes;
317 1 Time::HiRes->import(qw(gettimeofday tv_interval));
318 1 return;
319 13 };
320  
321 sub train_progress {
322 1 ▶ my ($self, $fh, $fast, $filename) = @_;
Subroutine train_progress: called CC=6 SCAR=18.6
323 1 my $lines = count_lines($filename);
324 my $progress = Term::Sk->new('%d Elapsed: %8t %21b %4p %2d (%c lines of %m)', {
325 # Start at line 1, not 0
326 base => 1,
327 target => $lines,
328 # Every 0.1 seconds for long files
329 freq => ($lines < 10_000 ? 10 : 'd'),
330 # Override Term::Sk's default 100_000 to 100,000
331 commify => sub {
332 14 ▶ my $int = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
333 14 $int = reverse $int;
334 14 $int =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g;
335 14 $int = reverse $int;
336 14 return $int;
337 },
338 1 ▶ }) or die "Error in Term::Sk->new: (code $Term::Sk::errcode) $Term::Sk::errmsg";
Branch: 2 branches
BranchTrueFalseTotal
my $progress = "Term::Sk"->new("%d Elapsed: %8t %21b %4p %2d (%c lines of %m)", {"base", 1, "target", $lines, "freq", $lines < 10000 ? 10 : "d", "commify", sub { my $int = shift(); $int = reverse($int); $int =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/gu; $int = reverse($int); return $int; } }) or die "Error in Term::Sk->new: (code $Term::Sk::errcode) $Term::Sk::errmsg" 0 1 1
$lines < 10000 ? : 1 0 1
339  
340 1 my $next_update = 0;
341 1 my $start_time = [gettimeofday()];
342  
343 1 ▶ my $i = 0; while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 61 1 62
344 61 $i++;
345 61 chomp $line;
346 61 $self->_learn_one($line, $fast);
347 61 ▶ $self->_engine->flush_cache if !$fast;
Branch: 1 branch
BranchTrueFalseTotal
unless $fast 61 0 61
348 61 $progress->up;
349 }
350  
351 1 $progress->close;
352  
353 1 ▶ if ($fast) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fast) 0 1 1
354 0 my $msg = "Flushing cache (this may take a while for large inputs)";
355 0 syswrite STDOUT, $msg;
356 0 $self->_engine->flush_cache;
357 0 print "\010" x length $msg;
358 }
359  
360 1 my $elapsed = tv_interval($start_time);
361 1 say sprintf "Trained from %d lines in %.2f seconds; %.2f lines/s", $i, $elapsed, ($i / $elapsed);
362  
363 1 return;
364 }
365  
366 # --i--do-not-exist
367 1 ▶sub _getopt_spec_exception { goto &_getopt_full_usage }
Subroutine _getopt_spec_exception: called CC=1 SCAR=0.0
368  
369 # --help
370 sub _getopt_full_usage {
371 5 ▶ my ($self, $usage, $plain_str) = @_;
Subroutine _getopt_full_usage: called CC=6 SCAR=17.9
372  
373 # If called from _getopt_spec_exception we get "Unknown option: foo"
374 5 ▶ my $warning = ref $usage eq 'ARRAY' ? $usage->[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $usage eq 'ARRAY' ? : 1 4 5
375  
376 5 my ($use, $options) = do {
377 # $plain_str under _getopt_spec_exception
378 5 ▶ my $out = $plain_str // $usage->text;
Condition66%2/3
$plain_str // $usage->text
l!l&&r!l&&!r
140
MC/DC0%0/2
$plain_str // $usage->text
$plain_str $usage->text
Truth table66%2/3
A // B
A= $plain_strB= $usage->text
ABresult
1X1
011
000
379  
380 # The default getopt order sucks, use reverse sort order
381 5 chomp(my @out = split /^/, $out);
382 5 my $opt = join "\n", sort { $b cmp $a } @out[1 .. $#out];
383 5 ($out[0], $opt);
384 };
385 5 my $synopsis = do {
386 5 require Pod::Usage;
387 5 my $out;
388 5 open my $fh, '>', \$out;
389  
390 13 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
391  
392 5 my $hailo = File::Spec->catfile($Hailo::Command::HERE_MOMMY, 'hailo');
393 # Try not to fail on Win32 or other odd systems which might have hailo.pl not hailo
394 5 ▶ $hailo = ((glob("$hailo*"))[0]) unless -f $hailo;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $hailo 0 5 5
395 5 Pod::Usage::pod2usage(
396 -input => $hailo,
397 -sections => 'SYNOPSIS',
398 -output => $fh,
399 -exitval => 'noexit',
400 );
401 5 close $fh;
402  
403 5 $out =~ s/\n+$//s;
404 5 $out =~ s/^Usage:/examples:/;
405  
406 5 $out;
407 };
408  
409 # Unknown option provided
410 5 ▶ print $warning if $warning;
Branch: 1 branch
BranchTrueFalseTotal
if $warning 1 4 5
411  
412 5 print <<"USAGE";
413 $use
414 $options
415 \n\tNote: All input/output and files are assumed to be UTF-8 encoded.
416 USAGE
417  
418 # Hack: We can't get at our object from here so we have to inspect
419 # @ARGV directly.
420 5 ▶ say "\n", $synopsis if "@ARGV" =~ /--examples/;
Branch: 1 branch
BranchTrueFalseTotal
if join($", @ARGV) =~ /--examples/u 1 4 5
421  
422 5 exit 1;
423 }
424  
425 13 __PACKAGE__->meta->make_immutable;
426  
427 =head1 NAME
428  
429 Hailo::Command - Class for the L<hailo> command-line interface to L<Hailo>
430  
431 =head1 DESCRIPTION
432  
433 This is an internal class L<hailo> uses for its command-line
434 interface. See L<Hailo> for the public interface.
435  
436 =head1 PRIVATE METHODS
437  
438 =head2 C<run>
439  
440 Run Hailo in accordance with the the attributes that were passed to
441 it, this method is called by the L<hailo> command-line utility and the
442 Hailo test suite, its behavior is subject to change.
443  
444 =head1 AUTHOR
445  
446 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
447  
448 =head1 LICENSE AND COPYRIGHT
449  
450 Copyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
451  
452 This program is free software, you can redistribute it and/or modify
453 it under the same terms as Perl itself.
454  
455 =cut
« blib/lib/Hailo/Tokenizer/Words.pm ↑ Summary blib/lib/Hailo/Storage/Schema.pm »