dbMan/Extension/CmdPager.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 64 CC 8 SCAR 23.3
CC
8
Cov
0%
cmdcomplete
20.0
handle_action
12.0
restart_complete
12.0
CRAP 10.2
1 package DBIx::dbMan::Extension::CmdPager;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.04';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000036-000004"; }
11  
12 sub preference { return 2000; }
13  
14 sub known_actions { return [ qw/COMMAND/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 $action{processed} = 1;
20 if ($action{action} eq 'COMMAND') {
21 if ($action{cmd} =~ s/^\\p\s+//i) {
22 ++$action{output_pager};
23 delete $action{processed};
24 }
25 }
26  
27 return %action;
28 }
29  
30 sub cmdhelp {
31 return [
32 '\p <command>' => 'Pager <command> (like less or more)',
33 ];
34 }
35  
36 sub restart_complete {
37 my ($obj,$text,$line,$start) = @_;
38 my %action = (action => 'LINE_COMPLETE', text => $text, line => $line,
39 start => $start);
40 do {
41 %action = $obj->{-core}->handle_action(%action);
42 } until ($action{processed});
43 return @{$action{list}} if ref $action{list} eq 'ARRAY';
44 return $action{list} if $action{list};
45 return ();
46 }
47  
48 sub cmdcomplete {
49 my ($obj,$text,$line,$start) = @_;
50 return $obj->restart_complete($text,$1,$start-(length($line)-length($1))) if $line =~ /^\s*\\p\s+(.*)$/i;
51 return ('\p') if $line =~ /^\s*$/i;
52 return ('p') if $line =~ /^\s*\\[A-Z]*$/i;
53 return ();
54 }