You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2012/10/15 19:32:24 UTC
[2/6] git commit: cqlsh: use libedit when readline is not available,
if possible Patch by Aleksey Yeschenko,
reviewed by brandonwilliams for CASSANDRA-3597
cqlsh: use libedit when readline is not available, if possible
Patch by Aleksey Yeschenko, reviewed by brandonwilliams for
CASSANDRA-3597
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2d83cfc2
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2d83cfc2
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2d83cfc2
Branch: refs/heads/trunk
Commit: 2d83cfc2bb51660d484ca02cb4343d0a3e8f2daa
Parents: 596d54c
Author: Brandon Williams <br...@apache.org>
Authored: Mon Oct 15 12:31:51 2012 -0500
Committer: Brandon Williams <br...@apache.org>
Committed: Mon Oct 15 12:31:51 2012 -0500
----------------------------------------------------------------------
bin/cqlsh | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d83cfc2/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 0a0f14c..bb440e0 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -121,6 +121,11 @@ DEFAULT_TRANSPORT_FACTORY = 'cqlshlib.tfactory.regular_transport_factory'
DEFAULT_TIME_FORMAT = '%Y-%m-%d %H:%M:%S%z'
DEFAULT_FLOAT_PRECISION = 3
+if readline is not None and 'libedit' in readline.__doc__:
+ DEFAULT_COMPLETEKEY = '\t'
+else:
+ DEFAULT_COMPLETEKEY = 'tab'
+
epilog = """Connects to %(DEFAULT_HOST)s:%(DEFAULT_PORT)d by default. These
defaults can be changed by setting $CQLSH_HOST and/or $CQLSH_PORT. When a
host (and optional port number) are given on the command line, they take
@@ -428,8 +433,8 @@ class Shell(cmd.Cmd):
def __init__(self, hostname, port, transport_factory, color=False,
username=None, password=None, encoding=None, stdin=None, tty=True,
- completekey='tab', use_conn=None, cqlver=None, keyspace=None,
- tracing_enabled=False,
+ completekey=DEFAULT_COMPLETEKEY, use_conn=None,
+ cqlver=None, keyspace=None, tracing_enabled=False,
display_time_format=DEFAULT_TIME_FORMAT,
display_float_precision=DEFAULT_FLOAT_PRECISION):
cmd.Cmd.__init__(self, completekey=completekey)
@@ -780,7 +785,11 @@ class Shell(cmd.Cmd):
else:
old_completer = readline.get_completer()
readline.set_completer(self.complete)
- readline.parse_and_bind(self.completekey+": complete")
+ if 'libedit' in readline.__doc__:
+ readline.parse_and_bind("bind -e")
+ readline.parse_and_bind("bind '" + self.completekey + "' rl_complete")
+ else:
+ readline.parse_and_bind(self.completekey + ": complete")
try:
yield
finally:
@@ -2692,7 +2701,8 @@ def read_options(cmdlineargs, environment):
optvalues.keyspace = option_with_default(configs.get, 'authentication', 'keyspace')
optvalues.transport_factory = option_with_default(configs.get, 'connection', 'factory',
DEFAULT_TRANSPORT_FACTORY)
- optvalues.completekey = option_with_default(configs.get, 'ui', 'completekey', 'tab')
+ optvalues.completekey = option_with_default(configs.get, 'ui', 'completekey',
+ DEFAULT_COMPLETEKEY)
optvalues.color = option_with_default(configs.getboolean, 'ui', 'color')
optvalues.time_format = raw_option_with_default(configs, 'ui', 'time_format',
DEFAULT_TIME_FORMAT)