| 1 | package DBIx::dbMan::Extension::CmdHistory; | ||
| 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-000034-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 | if ($action{action} eq 'COMMAND') { | ||
| 20 | if ($action{cmd} =~ /^show(\s+commands?)?\s+history$/i) { | ||
| 21 | $action{action} = 'HISTORY'; | ||
| 22 | $action{operation} = 'show'; | ||
| 23 | } elsif ($action{cmd} =~ /^(clear|erase)(\s+commands?)?\s+history$/i) { | ||
| 24 | $action{action} = 'HISTORY'; | ||
| 25 | $action{operation} = 'clear'; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | $action{processed} = 1; | ||
| 30 | return %action; | ||
| 31 | } | ||
| 32 | |||
| 33 | sub cmdhelp { | ||
| 34 | return [ | ||
| 35 | 'SHOW HISTORY' => 'Show commands history', | ||
| 36 | 'CLEAR HISTORY' => 'Clear commands history' | ||
| 37 | ]; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub cmdcomplete { | ||
| 41 | my ($obj,$text,$line,$start) = @_; | ||
| 42 | return qw/HISTORY/ if $line =~ /^\s*(SHOW|CLEAR)\s+\S*$/i; | ||
| 43 | return qw/SHOW CLEAR/ if $line =~ /^\s*[A-Z]*$/i; | ||
| 44 | return (); | ||
| 45 | } |