From 57740b8e129f1f361cd9c1a8f28f8857fa91eedc Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Sun, 30 May 2010 18:03:46 +0000 Subject: [PATCH] HBASE-2371. Fix 'list' command in shell git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@949549 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/main/ruby/shell/commands/list.rb | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 02fd9c513e3..0ff66ce8859 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -364,6 +364,7 @@ Release 0.21.0 - Unreleased (Christo Wilson via Stack) HBASE-2621 Fix bad link to HFile documentation in javadoc (Jeff Hammerbacher via Todd Lipcon) + HBASE-2371 Fix 'list' command in shell (Alexey Kovyrin via Todd Lipcon) IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/main/ruby/shell/commands/list.rb b/src/main/ruby/shell/commands/list.rb index 54ed481880e..5624be27e63 100644 --- a/src/main/ruby/shell/commands/list.rb +++ b/src/main/ruby/shell/commands/list.rb @@ -23,14 +23,25 @@ module Shell class List < Command def help return <<-EOF - List all tables in hbase + List all tables in hbase. Optional regular expression parameter could + be used to filter the output. Examples: + + hbase> list + hbase> list 'abc.*' EOF end - def command - format_simple_command do - admin.list + def command(regex = ".*") + now = Time.now + formatter.header([ "TABLE" ]) + + regex = /#{regex}/ unless regex.is_a?(Regexp) + list = admin.list.grep(regex) + list.each do |table| + formatter.row([ table ]) end + + formatter.footer(now, list.count) end end end