blib/lib/Hailo/Command.pm

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