dbMan/Extension/CmdSQLHelp.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 53 CC 6 SCAR 22.9
CC
6
Cov
0%
handle_action
20.0
cmdcomplete
12.0
IDENTIFICATION
2.0
CRAP 9.8
1 package DBIx::dbMan::Extension::CmdSQLHelp;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.03';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000058-000003"; }
11  
12 sub preference { return 1000; }
13  
14 sub known_actions { return [ qw/COMMAND/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'COMMAND') {
20 if ($action{cmd} =~ /^\\h(\s+(.+))?$/i) {
21 if ($1) {
22 $action{action} = 'HELP';
23 $action{type} = 'sql';
24 $action{what} = $2;
25 } else {
26 $action{action} = 'OUTPUT';
27 $action{output} = "You must specify SQL command for getting help.\n";
28 }
29 }
30 }
31  
32 $action{processed} = 1;
33 return %action;
34 }
35  
36 sub cmdhelp {
37 return [
38 '\h <sql>' => 'Show help for SQL command'
39 ];
40 }
41  
42 sub cmdcomplete {
43 my ($obj,$text,$line,$start) = @_;
44 return ('\h') if $line =~ /^\s*$/i;
45 return ('h') if $line =~ /^\s*\\[A-Z]*$/i;
46 return ();
47 }