From 271a3cbf13c2e253378d061ad17f9c8d7beff451 Mon Sep 17 00:00:00 2001 From: Elliot Date: Fri, 31 Jul 2020 10:41:49 -0400 Subject: [PATCH] HBASE-24803 Unify hbase-shell ::Shell::Commands::Command#help behavior (#2178) - Update all hbase-shell commands to return help text implicitly - Add hbase-shell test to ensure all help methods return unindented text - Set the outermost indentation to zero for the help text of all hbase-shell commands by using the squiggly heredoc added in Ruby 2.3.0. - Document return value of hbck_chore_run and add usage examples to truncate commands - Update docs to reflect current return value of list command Signed-off-by: stack --- .../shell/commands/append_peer_namespaces.rb | 2 +- .../shell/commands/clear_compaction_queues.rb | 2 +- .../ruby/shell/commands/clear_deadservers.rb | 2 +- .../ruby/shell/commands/clone_table_schema.rb | 2 +- .../src/main/ruby/shell/commands/compact.rb | 2 +- .../main/ruby/shell/commands/compact_rs.rb | 2 +- .../ruby/shell/commands/compaction_state.rb | 2 +- .../ruby/shell/commands/compaction_switch.rb | 2 +- .../commands/decommission_regionservers.rb | 2 +- .../shell/commands/disable_rpc_throttle.rb | 2 +- .../shell/commands/enable_rpc_throttle.rb | 2 +- .../ruby/shell/commands/get_peer_config.rb | 2 +- .../ruby/shell/commands/hbck_chore_run.rb | 3 ++- .../ruby/shell/commands/list_deadservers.rb | 2 +- .../list_decommissioned_regionservers.rb | 2 +- .../ruby/shell/commands/list_peer_configs.rb | 2 +- .../main/ruby/shell/commands/list_peers.rb | 2 +- .../main/ruby/shell/commands/list_regions.rb | 5 ++--- .../main/ruby/shell/commands/major_compact.rb | 2 +- .../shell/commands/move_namespaces_rsgroup.rb | 2 +- .../move_servers_namespaces_rsgroup.rb | 2 +- .../commands/recommission_regionserver.rb | 2 +- .../shell/commands/remove_peer_namespaces.rb | 2 +- .../commands/set_peer_exclude_namespaces.rb | 2 +- .../commands/set_peer_exclude_tableCFs.rb | 2 +- .../shell/commands/set_peer_namespaces.rb | 2 +- .../shell/commands/set_peer_replicate_all.rb | 2 +- .../ruby/shell/commands/set_peer_serial.rb | 2 +- .../ruby/shell/commands/set_peer_tableCFs.rb | 2 +- .../ruby/shell/commands/show_peer_tableCFs.rb | 2 +- .../shell/commands/splitormerge_enabled.rb | 4 ++-- .../shell/commands/splitormerge_switch.rb | 4 ++-- .../src/main/ruby/shell/commands/truncate.rb | 5 ++++- .../ruby/shell/commands/truncate_preserve.rb | 7 +++++-- .../src/test/ruby/shell/commands_test.rb | 21 +++++++++++++++++-- src/main/asciidoc/_chapters/shell.adoc | 2 +- 36 files changed, 65 insertions(+), 42 deletions(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb index f48cd46b7ef..59657d8f3c9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb @@ -22,7 +22,7 @@ module Shell module Commands class AppendPeerNamespaces < Command def help - <<-EOF + <<~EOF Append some namespaces to be replicable for the specified peer. Set a namespace in the peer config means that all tables in this diff --git a/hbase-shell/src/main/ruby/shell/commands/clear_compaction_queues.rb b/hbase-shell/src/main/ruby/shell/commands/clear_compaction_queues.rb index 7a5c374b965..f5f94a975f2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clear_compaction_queues.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clear_compaction_queues.rb @@ -21,7 +21,7 @@ module Shell module Commands class ClearCompactionQueues < Command def help - <<-EOF + <<~EOF Clear compacting queues on a regionserver. The queue_name contains short and long. short is shortCompactions's queue,long is longCompactions's queue. diff --git a/hbase-shell/src/main/ruby/shell/commands/clear_deadservers.rb b/hbase-shell/src/main/ruby/shell/commands/clear_deadservers.rb index afbf2e1c41c..e7edeb685e6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clear_deadservers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clear_deadservers.rb @@ -21,7 +21,7 @@ module Shell module Commands class ClearDeadservers < Command def help - <<-EOF + <<~EOF Clear the dead region servers that are never used. Returns an array containing any deadservers that could not be cleared. diff --git a/hbase-shell/src/main/ruby/shell/commands/clone_table_schema.rb b/hbase-shell/src/main/ruby/shell/commands/clone_table_schema.rb index a92e86246b8..12dc77794cc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clone_table_schema.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clone_table_schema.rb @@ -21,7 +21,7 @@ module Shell # create a new table by cloning the existent table schema. class CloneTableSchema < Command def help - <<-HELP + <<~HELP Create a new table by cloning the existent table schema. There're no copies of data involved. Just copy the table descriptor and split keys. diff --git a/hbase-shell/src/main/ruby/shell/commands/compact.rb b/hbase-shell/src/main/ruby/shell/commands/compact.rb index a1c44c3b604..16edeb37fea 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compact.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compact.rb @@ -21,7 +21,7 @@ module Shell module Commands class Compact < Command def help - <<-EOF + <<~EOF Compact all regions in passed table or pass a region row to compact an individual region. You can also compact a single column family within a region. diff --git a/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb b/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb index f10230af8b8..2dc62c166cd 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb @@ -21,7 +21,7 @@ module Shell module Commands class CompactRs < Command def help - <<-EOF + <<~EOF Compact all regions on passed regionserver. Examples: Compact all regions on a regionserver: diff --git a/hbase-shell/src/main/ruby/shell/commands/compaction_state.rb b/hbase-shell/src/main/ruby/shell/commands/compaction_state.rb index 05b75210c99..4df7f079872 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compaction_state.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compaction_state.rb @@ -21,7 +21,7 @@ module Shell module Commands class CompactionState < Command def help - <<-EOF + <<~EOF Gets compaction status (MAJOR, MAJOR_AND_MINOR, MINOR, NONE) for a table: hbase> compaction_state 'ns1:t1' hbase> compaction_state 't1' diff --git a/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb b/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb index 6a58bbe5d56..d26323312f6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compaction_switch.rb @@ -22,7 +22,7 @@ module Shell # Switch compaction for a region server class CompactionSwitch < Command def help - <<-EOF + <<~EOF Turn the compaction on or off on regionservers. Disabling compactions will also interrupt any currently ongoing compactions. This state is ephemeral. The setting will be lost on restart of the server. Compaction can also be enabled/disabled by modifying configuration diff --git a/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb b/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb index 65ac1039c07..3fcb1838e66 100644 --- a/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb @@ -22,7 +22,7 @@ module Shell # Decommission a list of region servers, optionally offload corresponding regions class DecommissionRegionservers < Command def help - <<-EOF + <<~EOF Mark region server(s) as decommissioned to prevent additional regions from getting assigned to them. diff --git a/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb b/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb index 1313125a8e1..03652afeb9d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb @@ -21,7 +21,7 @@ module Shell module Commands class DisableRpcThrottle < Command def help - return <<-EOF + <<-EOF Disable quota rpc throttle. Returns previous rpc throttle enabled value. NOTE: if quota is not enabled, this will not work and always return false. diff --git a/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb b/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb index 12c91b17924..f992b7ceebd 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb @@ -21,7 +21,7 @@ module Shell module Commands class EnableRpcThrottle < Command def help - return <<-EOF + <<-EOF Enable quota rpc throttle. Returns previous rpc throttle enabled value. NOTE: if quota is not enabled, this will not work and always return false. diff --git a/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb b/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb index 81f738ebcb9..3f4a9492c91 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb @@ -19,7 +19,7 @@ module Shell module Commands class GetPeerConfig < Command def help - <<-EOF + <<~EOF Outputs the cluster key, replication endpoint class (if present), and any replication configuration parameters EOF end diff --git a/hbase-shell/src/main/ruby/shell/commands/hbck_chore_run.rb b/hbase-shell/src/main/ruby/shell/commands/hbck_chore_run.rb index 4f77ead472a..47ff636c831 100644 --- a/hbase-shell/src/main/ruby/shell/commands/hbck_chore_run.rb +++ b/hbase-shell/src/main/ruby/shell/commands/hbck_chore_run.rb @@ -23,7 +23,8 @@ module Shell <<-EOF Request HBCK chore to run at master side. It will try to find the orphan regions on RegionServer or FileSystem and find the inconsistent regions. -You can check the HBCK report at Master web UI. +You can check the HBCK report at Master web UI. Returns true if HBCK chore +ran, or false if HBCK chore is already running. hbase> hbck_chore_run diff --git a/hbase-shell/src/main/ruby/shell/commands/list_deadservers.rb b/hbase-shell/src/main/ruby/shell/commands/list_deadservers.rb index 735fdaa82c2..133dcfa1873 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_deadservers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_deadservers.rb @@ -21,7 +21,7 @@ module Shell module Commands class ListDeadservers < Command def help - <<-EOF + <<~EOF List all dead region servers in hbase Examples: hbase> list_deadservers diff --git a/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb b/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb index 49a6e81d6e6..5e03cfd9521 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb @@ -22,7 +22,7 @@ module Shell # List decommissioned region servers class ListDecommissionedRegionservers < Command def help - <<-EOF + <<~EOF List region servers marked as decommissioned, which can not be assigned regions. EOF end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb b/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb index 12fb301862e..85edc7e76d0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb @@ -19,7 +19,7 @@ module Shell module Commands class ListPeerConfigs < Command def help - <<-EOF + <<~EOF No-argument method that outputs the replication peer configuration for each peer defined on this cluster. EOF end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_peers.rb b/hbase-shell/src/main/ruby/shell/commands/list_peers.rb index eefcc426a39..40816a4891a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_peers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_peers.rb @@ -22,7 +22,7 @@ module Shell module Commands class ListPeers < Command def help - <<-EOF + <<~EOF List all replication peer clusters. If replicate_all flag is false, the namespaces and table-cfs in peer config diff --git a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb index f63ff786d0a..f7bc825617a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -21,7 +21,7 @@ module Shell module Commands class ListRegions < Command def help - return < list_regions 'table_name', {}, ['SERVER_NAME', 'start_key'] hbase> list_regions 'table_name', '', ['SERVER_NAME', 'start_key'] -EOF - nil + EOF end def command(table_name, options = nil, cols = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/major_compact.rb b/hbase-shell/src/main/ruby/shell/commands/major_compact.rb index 9ff26c16eb8..75d2838d569 100644 --- a/hbase-shell/src/main/ruby/shell/commands/major_compact.rb +++ b/hbase-shell/src/main/ruby/shell/commands/major_compact.rb @@ -21,7 +21,7 @@ module Shell module Commands class MajorCompact < Command def help - <<-EOF + <<~EOF Run major compaction on passed table or pass a region row to major compact an individual region. To compact a single column family within a region specify the region name diff --git a/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb index 0151f7aec6a..7878eb9317c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb @@ -21,7 +21,7 @@ module Shell # from one RegionServer group to another. class MoveNamespacesRsgroup < Command def help - <<-CMD + <<~CMD Example: hbase> move_namespaces_rsgroup 'dest',['ns1','ns2'] diff --git a/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb index 16b1ce996c1..93db81a5466 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb @@ -21,7 +21,7 @@ module Shell # specified namespaces from one group to another. class MoveServersNamespacesRsgroup < Command def help - <<-CMD + <<~CMD Example: hbase> move_servers_namespaces_rsgroup 'dest',['server1:port','server2:port'],['ns1','ns2'] diff --git a/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb b/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb index 125eebce593..b112a8d498e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb +++ b/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb @@ -22,7 +22,7 @@ module Shell # Recommission a region server, optionally load a list of passed regions class RecommissionRegionserver < Command def help - <<-EOF + <<~EOF Remove decommission marker from a region server to allow regions assignments. Optionally, load regions onto the server by passing a list of encoded region names. diff --git a/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb index 79b56d90cd9..fc771313ba4 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb @@ -22,7 +22,7 @@ module Shell module Commands class RemovePeerNamespaces < Command def help - <<-EOF + <<~EOF Remove some namespaces from the namespaces config for the specified peer. Examples: diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb index bf9b90b45bd..bc8d8674830 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb @@ -22,7 +22,7 @@ module Shell module Commands class SetPeerExcludeNamespaces < Command def help - <<-EOF + <<~EOF Set the namespaces which not replicated for the specified peer. Note: diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb index ccb1329cfa2..4727790fb4d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb @@ -22,7 +22,7 @@ module Shell module Commands class SetPeerExcludeTableCFs < Command def help - <<-EOF + <<~EOF Set the table-cfs which not replicated for the specified peer. Note: diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb index 9f0649dabd4..ee14a9ac8dc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb @@ -22,7 +22,7 @@ module Shell module Commands class SetPeerNamespaces < Command def help - <<-EOF + <<~EOF Set the replicable namespaces config for the specified peer. 1. The replicate_all flag need to be false when set the replicable namespaces. diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb index 89969647e5f..87ffa02fcdd 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb @@ -22,7 +22,7 @@ module Shell module Commands class SetPeerReplicateAll < Command def help - <<-EOF + <<~EOF Set the replicate_all flag to true or false for the specified peer. If replicate_all flag is true, then all user tables (REPLICATION_SCOPE != 0) diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb index a6484cd702b..cb18182dd33 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb @@ -22,7 +22,7 @@ module Shell module Commands class SetPeerSerial < Command def help - <<-EOF + <<~EOF Set the serial flag to true or false for the specified peer. If serial flag is true, then all logs of user tables (REPLICATION_SCOPE != 0) will be diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb index 03b21862a97..73d57edc349 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb @@ -22,7 +22,7 @@ module Shell module Commands class SetPeerTableCFs < Command def help - <<-EOF + <<~EOF Set the replicable table-cf config for the specified peer. Note: diff --git a/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb index c2a3f7a526c..48197a7ff17 100644 --- a/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb @@ -22,7 +22,7 @@ module Shell module Commands class ShowPeerTableCFs < Command def help - <<-EOF + <<~EOF Show replicable table-cf config for the specified peer. hbase> show_peer_tableCFs '2' diff --git a/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb index 4ca13d2cb69..be5d3db0f31 100644 --- a/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb @@ -21,12 +21,12 @@ module Shell # Command for check split or merge switch status class SplitormergeEnabled < Command def help - print <<-EOF + <<-EOF Query the switch's state. You can set switch type, 'SPLIT' or 'MERGE' Examples: hbase> splitormerge_enabled 'SPLIT' -EOF + EOF end def command(switch_type) diff --git a/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb b/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb index cb6253485da..22888f29870 100644 --- a/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb @@ -22,13 +22,13 @@ module Shell # Command for set switch for split and merge class SplitormergeSwitch < Command def help - print <<-EOF + <<-EOF Enable/Disable one switch. You can set switch type 'SPLIT' or 'MERGE'. Returns previous split state. Examples: hbase> splitormerge_switch 'SPLIT', true hbase> splitormerge_switch 'SPLIT', false -EOF + EOF end def command(switch_type, enabled) diff --git a/hbase-shell/src/main/ruby/shell/commands/truncate.rb b/hbase-shell/src/main/ruby/shell/commands/truncate.rb index 8c9f30e8e29..0a061fbf78e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate.rb @@ -21,8 +21,11 @@ module Shell module Commands class Truncate < Command def help - <<-EOF + <<~EOF Disables, drops and recreates the specified table. + + Example: + hbase> truncate 'my_table' EOF end diff --git a/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb b/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb index 59be7d6193a..21959512232 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb @@ -21,8 +21,11 @@ module Shell module Commands class TruncatePreserve < Command def help - <<-EOF - Disables, drops and recreates the specified table while still maintaing the previous region boundaries. + <<~EOF + Disables, drops and recreates the specified table while still maintaining the previous region boundaries. + + Example: + hbase> truncate_preserve 'my_table' EOF end diff --git a/hbase-shell/src/test/ruby/shell/commands_test.rb b/hbase-shell/src/test/ruby/shell/commands_test.rb index 0106099fd77..0fc3dab4110 100644 --- a/hbase-shell/src/test/ruby/shell/commands_test.rb +++ b/hbase-shell/src/test/ruby/shell/commands_test.rb @@ -25,9 +25,26 @@ require 'shell' # Tests whether all registered commands have a help and command method class ShellCommandsTest < Test::Unit::TestCase + + ## + # Determine the indentation of the given text + # + # @param [String] text + # @return [Integer] number of whitespace characters used for indentation + def determine_indentation(text) + # Ignore lines only containing whitespace. For all other lines, capture + # the number of whitespace characters preceding the first non-whitespace + # character. Return the minimum number found. + text.scan(/^([ \t]*)[^\s].*$/).flatten.map { |space| space.length }.min + end + Shell.commands.each do |name, klass| - define_test "#{name} command class #{klass} should respond to help" do - assert_respond_to(klass.new(nil), :help) + define_test "#{name} command class #{klass} should return help" do + result = klass.new(nil).help + # check that help text exists and is non-empty + assert(result.is_a?(String) && result.length > 0) + # check that the help text is not indented + assert(determine_indentation(result) == 0) end define_test "#{name} command class #{klass} should respond to :command" do diff --git a/src/main/asciidoc/_chapters/shell.adoc b/src/main/asciidoc/_chapters/shell.adoc index cdfa8286ed4..9ec6fca1884 100644 --- a/src/main/asciidoc/_chapters/shell.adoc +++ b/src/main/asciidoc/_chapters/shell.adoc @@ -324,7 +324,7 @@ TABLE t 1 row(s) in 0.1040 seconds -=> #<#:0x21d377a4> +=> ["t"] hbase(main):017:0> tables.map { |t| disable t ; drop t} 0 row(s) in 2.2510 seconds