dbMan/Extension/CmdShowErrors.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 79 CC 8 SCAR 25.7
CC
8
Cov
0%
cmdcomplete
30.0
handle_action
12.0
menu
6.0
CRAP 13.1
1 package DBIx::dbMan::Extension::CmdShowErrors;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.05';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000046-000005"; }
11  
12 sub preference { return 2000; }
13  
14 sub known_actions { return [ qw/COMMAND/ ]; }
15  
16 sub menu {
17 my $obj = shift;
18  
19 if ($obj->{-dbi}->current and $obj->{-dbi}->driver eq 'Oracle') {
20 return ( { label => 'Connection', submenu => [
21 { label => 'Show errors', preference => -800,
22 action => { action => 'COMMAND', cmd => 'show errors' } },
23 { separator => 1, preference => -500 }
24 ] } );
25 } else {
26 return ();
27 }
28 }
29  
30 sub handle_action {
31 my ($obj,%action) = @_;
32  
33 if ($action{action} eq 'COMMAND' and $obj->{-dbi}->current and $obj->{-dbi}->driver eq 'Oracle') {
34 if ($action{cmd} =~ /^show\s+errors?$/i) {
35 $action{action} = 'SQL';
36 $action{type} = 'select';
37 $action{sql} = 'SELECT name,type,line,position,text FROM user_errors ORDER BY name,type,sequence';
38 return %action;
39 }
40 }
41  
42 $action{processed} = 1;
43 return %action;
44 }
45  
46 sub cmdhelp {
47 return [
48 'SHOW ERRORS' => 'Show errors in Oracle objects (only for Oracle)'
49 ];
50 }
51  
52 sub cmdcomplete {
53 my ($obj,$text,$line,$start) = @_;
54 return unless $obj->{-dbi}->current;
55 return unless $obj->{-dbi}->driver eq 'Oracle';
56 return qw/ERRORS/ if $line =~ /^\s*SHOW\s+\S*$/i;
57 return qw/SHOW/ if $line =~ /^\s*[A-Z]*$/i;
58 return ();
59 }