dbMan/Extension/CmdHelp.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 56 CC 7 SCAR 26.5
CC
7
Cov
0%
handle_action
30.0
cmdcomplete
12.0
IDENTIFICATION
2.0
CRAP 14.1
1 package DBIx::dbMan::Extension::CmdHelp;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.08';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000009-000008"; }
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} =~ /^help(?:\s+(.+))?$/i) {
21 $action{action} = 'HELP';
22 $action{type} = 'commands';
23 $action{what} = $1;
24 } elsif ($action{cmd} =~ /^(show\s+)?versions?$/i) {
25 $action{action} = 'HELP';
26 $action{type} = 'version';
27 } elsif ($action{cmd} =~ /^(show\s+)?licen[cs]e$/i) {
28 $action{action} = 'HELP';
29 $action{type} = 'license';
30 }
31 }
32  
33 $action{processed} = 1;
34 return %action;
35 }
36  
37 sub cmdhelp {
38 return [
39 'HELP' => 'Show this help',
40 'SHOW VERSION' => 'Show dbMan'."'".'s version',
41 'SHOW LICENSE' => 'Show dbMan'."'".'s license'
42 ];
43 }
44  
45 sub cmdcomplete {
46 my ($obj,$text,$line,$start) = @_;
47 return qw/VERSION LICENSE/ if $line =~ /^\s*SHOW\s+[A-Z]*$/i;
48 return qw/HELP SHOW/ if $line =~ /^\s*[A-Z]*$/i;
49 return ();
50 }