| 1 | package DBIx::dbMan::Extension::CmdShowTables; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'DBIx::dbMan::Extension'; | ||
| 5 | |||
| 6 | our $VERSION = '0.06'; | ||
| 7 | |||
| 8 | 1; | ||
| 9 | |||
| 10 | sub IDENTIFICATION { return "000001-000019-000006"; } | ||
| 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+(object|table|view|sequence)s?|\\dt)(?:\s+(\S+))?$/i) { | ||
| 21 | $action{action} = 'SHOW_TABLES'; | ||
| 22 | $action{type} = lc $1; | ||
| 23 | $action{type} = 'table' unless $action{type}; | ||
| 24 | $action{mask} = uc $2; | ||
| 25 | $action{mask} = '^' if $action{mask} eq ''; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | $action{processed} = 1; | ||
| 30 | return %action; | ||
| 31 | } | ||
| 32 | |||
| 33 | sub cmdhelp { | ||
| 34 | return [ | ||
| 35 | 'SHOW [OBJECTS|TABLES|VIEWS|SEQUENCES] [<RE-filter>]' => 'Show tables/views/sequences/all objects in current connection' | ||
| 36 | ]; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub cmdcomplete { | ||
| 40 | my ($obj,$text,$line,$start) = @_; | ||
| 41 | return () unless $obj->{-dbi}->current; | ||
| 42 | return qw/OBJECTS TABLES VIEWS SEQUENCES/ if $line =~ /^\s*SHOW\s+\S*$/i; | ||
| 43 | return ('SHOW','\dt') if $line =~ /^\s*$/; | ||
| 44 | return ('dt') if $line =~ /^\s*\\[A-Z]*$/i; | ||
| 45 | return qw/SHOW/ if $line =~ /^\s*[A-Z]*$/i; | ||
| 46 | return (); | ||
| 47 | } |