HBASE-2632. Shell should autodetect terminal width
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@949803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
57740b8e12
commit
12855081cc
|
@ -651,6 +651,7 @@ Release 0.21.0 - Unreleased
|
||||||
HBASE-2599 BaseScanner says "Current assignment of X is not valid" over
|
HBASE-2599 BaseScanner says "Current assignment of X is not valid" over
|
||||||
and over for same region
|
and over for same region
|
||||||
HBASE-2630 HFile should use toStringBinary in various places
|
HBASE-2630 HFile should use toStringBinary in various places
|
||||||
|
HBASE-2632 Shell should autodetect terminal width
|
||||||
|
|
||||||
NEW FEATURES
|
NEW FEATURES
|
||||||
HBASE-1961 HBase EC2 scripts
|
HBASE-1961 HBase EC2 scripts
|
||||||
|
|
|
@ -53,12 +53,10 @@ end
|
||||||
cmdline_help = <<HERE # HERE document output as shell usage
|
cmdline_help = <<HERE # HERE document output as shell usage
|
||||||
HBase Shell command-line options:
|
HBase Shell command-line options:
|
||||||
format Formatter for outputting results: console | html. Default: console
|
format Formatter for outputting results: console | html. Default: console
|
||||||
format-width Width of table outputs. Default: 110 characters.
|
|
||||||
-d | --debug Set DEBUG log levels.
|
-d | --debug Set DEBUG log levels.
|
||||||
HERE
|
HERE
|
||||||
found = []
|
found = []
|
||||||
format = 'console'
|
format = 'console'
|
||||||
format_width = 110
|
|
||||||
script2run = nil
|
script2run = nil
|
||||||
log_level = org.apache.log4j.Level::ERROR
|
log_level = org.apache.log4j.Level::ERROR
|
||||||
for arg in ARGV
|
for arg in ARGV
|
||||||
|
@ -72,9 +70,6 @@ for arg in ARGV
|
||||||
raise ArgumentError.new("Unsupported format " + arg)
|
raise ArgumentError.new("Unsupported format " + arg)
|
||||||
end
|
end
|
||||||
found.push(arg)
|
found.push(arg)
|
||||||
elsif arg =~ /^--format-width=(.+)/i
|
|
||||||
format_width = $1.to_i
|
|
||||||
found.push(arg)
|
|
||||||
elsif arg == '-h' || arg == '--help'
|
elsif arg == '-h' || arg == '--help'
|
||||||
puts cmdline_help
|
puts cmdline_help
|
||||||
exit
|
exit
|
||||||
|
@ -110,7 +105,7 @@ require 'shell/formatter'
|
||||||
|
|
||||||
# Presume console format.
|
# Presume console format.
|
||||||
# Formatter takes an :output_stream parameter, if you don't want STDOUT.
|
# Formatter takes an :output_stream parameter, if you don't want STDOUT.
|
||||||
@formatter = Shell::Formatter::Console.new(:format_width => format_width)
|
@formatter = Shell::Formatter::Console.new
|
||||||
|
|
||||||
# Setup the HBase module. Create a configuration.
|
# Setup the HBase module. Create a configuration.
|
||||||
@hbase = Hbase::Hbase.new
|
@hbase = Hbase::Hbase.new
|
||||||
|
|
|
@ -29,15 +29,18 @@ module Shell
|
||||||
obj.instance_of?(IO) || obj == Kernel
|
obj.instance_of?(IO) || obj == Kernel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refresh_width()
|
||||||
|
@max_width = Java::jline.Terminal.getTerminal().getTerminalWidth()
|
||||||
|
end
|
||||||
|
|
||||||
# Takes an output stream and a print width.
|
# Takes an output stream and a print width.
|
||||||
def initialize(opts = {})
|
def initialize(opts = {})
|
||||||
options = {
|
options = {
|
||||||
:output_stream => Kernel,
|
:output_stream => Kernel,
|
||||||
:format_width => 100
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
@out = options[:output_stream]
|
@out = options[:output_stream]
|
||||||
@max_width = options[:format_width]
|
refresh_width
|
||||||
@row_count = 0
|
@row_count = 0
|
||||||
|
|
||||||
# raise an error if the stream is not valid
|
# raise an error if the stream is not valid
|
||||||
|
@ -45,6 +48,7 @@ module Shell
|
||||||
end
|
end
|
||||||
|
|
||||||
def header(args = [], widths = [])
|
def header(args = [], widths = [])
|
||||||
|
refresh_width
|
||||||
row(args, false, widths) if args.length > 0
|
row(args, false, widths) if args.length > 0
|
||||||
@row_count = 0
|
@row_count = 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ require 'hbase'
|
||||||
module Hbase
|
module Hbase
|
||||||
class HbaseTest < Test::Unit::TestCase
|
class HbaseTest < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@formatter = Shell::Formatter::Console.new(:format_width => 110)
|
@formatter = Shell::Formatter::Console.new()
|
||||||
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
|
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ require 'shell/formatter'
|
||||||
|
|
||||||
class ShellTest < Test::Unit::TestCase
|
class ShellTest < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@formatter = ::Shell::Formatter::Console.new(:format_width => 110)
|
@formatter = ::Shell::Formatter::Console.new()
|
||||||
@hbase = ::Hbase::Hbase.new
|
@hbase = ::Hbase::Hbase.new
|
||||||
@shell = Shell::Shell.new(@hbase, @formatter)
|
@shell = Shell::Shell.new(@hbase, @formatter)
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ end
|
||||||
module Hbase
|
module Hbase
|
||||||
module TestHelpers
|
module TestHelpers
|
||||||
def setup_hbase
|
def setup_hbase
|
||||||
@formatter = Shell::Formatter::Console.new(:format_width => 110)
|
@formatter = Shell::Formatter::Console.new()
|
||||||
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
|
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue