You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/09/17 18:44:19 UTC
[5/5] git commit: cqlsh: combine multiline statements into single
line history Patch by Matthew Horsfall,
reviewed by brandonwilliams for CASSANDRA-4666
cqlsh: combine multiline statements into single line history
Patch by Matthew Horsfall, reviewed by brandonwilliams for
CASSANDRA-4666
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5551d9c3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5551d9c3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5551d9c3
Branch: refs/heads/trunk
Commit: 5551d9c396d63cc844ce2db2c7d94aa9ca942d6b
Parents: 751e58d
Author: Brandon Williams <br...@apache.org>
Authored: Thu Sep 13 15:47:26 2012 -0500
Committer: Brandon Williams <br...@apache.org>
Committed: Thu Sep 13 15:47:26 2012 -0500
----------------------------------------------------------------------
bin/cqlsh | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5551d9c3/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index b2a11e3..3bef142 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -552,6 +552,7 @@ class Shell(cmd.Cmd):
show_line_nums = False
debug = False
stop = False
+ last_hist = None
shunted_query_out = None
csv_dialect_defaults = dict(delimiter=',', doublequote=False,
escapechar='\\', quotechar='"')
@@ -941,6 +942,16 @@ class Shell(cmd.Cmd):
self.do_exit()
def handle_statement(self, tokens, srcstr):
+ # Concat multi-line statements and insert into history
+ if readline is not None:
+ nl_count = srcstr.count("\n")
+
+ new_hist = srcstr.replace("\n", " ").rstrip()
+
+ if nl_count > 1 and self.last_hist != new_hist:
+ readline.add_history(new_hist)
+
+ self.last_hist = new_hist
cmdword = tokens[0][1]
if cmdword == '?':
cmdword = 'help'