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
[3/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/4d2e5e73
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4d2e5e73
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4d2e5e73
Branch: refs/heads/trunk
Commit: 4d2e5e73b127dc0b335176ddc1dec1f0244e7f6d
Parents: a0900f3
Author: Brandon Williams <br...@apache.org>
Authored: Mon Oct 15 12:29:40 2012 -0500
Committer: Brandon Williams <br...@apache.org>
Committed: Mon Oct 15 12:29:40 2012 -0500
----------------------------------------------------------------------
bin/cqlsh | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d2e5e73/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 02acd47..1b282bd 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -116,6 +116,11 @@ DEFAULT_CQLVER = '2'
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
@@ -560,7 +565,8 @@ class Shell(cmd.Cmd):
def __init__(self, hostname, port, color=False, username=None,
password=None, encoding=None, stdin=None, tty=True,
- completekey='tab', use_conn=None, cqlver=None, keyspace=None,
+ completekey=DEFAULT_COMPLETEKEY, use_conn=None,
+ cqlver=None, keyspace=None,
display_time_format=DEFAULT_TIME_FORMAT,
display_float_precision=DEFAULT_FLOAT_PRECISION):
cmd.Cmd.__init__(self, completekey=completekey)
@@ -851,7 +857,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:
@@ -2652,7 +2662,8 @@ def read_options(cmdlineargs, environment):
optvalues.username = option_with_default(configs.get, 'authentication', 'username')
optvalues.password = option_with_default(configs.get, 'authentication', 'password')
optvalues.keyspace = option_with_default(configs.get, 'authentication', 'keyspace')
- 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)