hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [1/3] git commit: HBASE-8298 In shell, provide alias of 'desc' for 'describe'.
Date Sat, 23 Aug 2014 17:47:25 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 e390a2fc0 -> 974689842
  refs/heads/branch-1 4ba7f67f8 -> 08c14bd50
  refs/heads/master d281ffb13 -> f69a1945c


HBASE-8298 In shell, provide alias of 'desc' for 'describe'.

* Adds ability to alias commands
* map 'desc' alias to 'describe'

Signed-off-by: Andrew Purtell <apurtell@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f69a1945
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f69a1945
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f69a1945

Branch: refs/heads/master
Commit: f69a1945c641c3eaba6a519e7a65eb54ce71f628
Parents: d281ffb
Author: Sean Busbey <busbey@apache.org>
Authored: Thu Aug 21 11:12:42 2014 -0500
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Sat Aug 23 10:39:42 2014 -0700

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/shell.rb                   | 15 ++++++++++++---
 hbase-shell/src/main/ruby/shell/commands/describe.rb |  4 ++++
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f69a1945/hbase-shell/src/main/ruby/shell.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb
index 61e1346..5b59254 100644
--- a/hbase-shell/src/main/ruby/shell.rb
+++ b/hbase-shell/src/main/ruby/shell.rb
@@ -29,7 +29,7 @@ module Shell
     @@command_groups
   end
 
-  def self.load_command(name, group)
+  def self.load_command(name, group, aliases=[])
     return if commands[name]
 
     # Register command in the group
@@ -41,6 +41,9 @@ module Shell
       require "shell/commands/#{name}"
       klass_name = name.to_s.gsub(/(?:^|_)(.)/) { $1.upcase } # camelize
       commands[name] = eval("Commands::#{klass_name}")
+      aliases.each do |an_alias|
+        commands[an_alias] = commands[name]
+      end
     rescue => e
       raise "Can't load hbase shell command: #{name}. Error: #{e}\n#{e.backtrace.join("\n")}"
     end
@@ -56,8 +59,11 @@ module Shell
       :comment => opts[:comment]
     }
 
+    all_aliases = opts[:aliases] || {}
+
     opts[:commands].each do |command|
-      load_command(command, group)
+      aliases = all_aliases[command] || []
+      load_command(command, group, aliases)
     end
   end
 
@@ -257,7 +263,10 @@ Shell.load_command_group(
     alter_status
     alter_async
     get_table
-  ]
+  ],
+  :aliases => {
+    'describe' => ['desc']
+  }
 )
 
 Shell.load_command_group(

http://git-wip-us.apache.org/repos/asf/hbase/blob/f69a1945/hbase-shell/src/main/ruby/shell/commands/describe.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/describe.rb b/hbase-shell/src/main/ruby/shell/commands/describe.rb
index 9e2996f..9e48491 100644
--- a/hbase-shell/src/main/ruby/shell/commands/describe.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/describe.rb
@@ -25,6 +25,10 @@ module Shell
 Describe the named table. For example:
   hbase> describe 't1'
   hbase> describe 'ns1:t1'
+
+Alternatively, you can use the abbreviated 'desc' for the same thing.
+  hbase> desc 't1'
+  hbase> desc 'nds1:t1'
 EOF
       end
 


Mime
View raw message