From e9bdb6a95c45dc4fc328a5c3a036bb1622857049 Mon Sep 17 00:00:00 2001 From: Mikhail Stepura Date: Fri, 2 May 2014 15:57:57 -0700 Subject: [PATCH] Issue a warning after 3 empty lines in statement patch by Mikhail Stepura; reviewed by Brandon Williams for CASSANDRA-7142 --- CHANGES.txt | 1 + bin/cqlsh | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 85707843e2..f4e14d809f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,7 @@ * Plug holes in resource release when wiring up StreamSession (CASSANDRA-7073) * Re-add parameter columns to tracing session (CASSANDRA-6942) * Fix writetime/ttl functions for static columns (CASSANDRA-7081) + * Suggest CTRL-C or semicolon after three blank lines in cqlsh (CASSANDRA-7142) Merged from 1.2: * Add Cloudstack snitch (CASSANDRA-7147) * Update system.peers correctly when relocating tokens (CASSANDRA-7126) diff --git a/bin/cqlsh b/bin/cqlsh index 6fa3afe321..020bd2a286 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -519,6 +519,7 @@ class Shell(cmd.Cmd): self.show_line_nums = True self.stdin = stdin self.query_out = sys.stdout + self.empty_lines = 0 def set_expanded_cql_version(self, ver): ver, vertuple = full_cql_version(ver) @@ -703,6 +704,7 @@ class Shell(cmd.Cmd): def reset_statement(self): self.reset_prompt() self.statement.truncate(0) + self.empty_lines = 0; def reset_prompt(self): if self.current_keyspace is None: @@ -711,11 +713,16 @@ class Shell(cmd.Cmd): self.set_prompt(self.keyspace_prompt % self.current_keyspace) def set_continue_prompt(self): + if self.empty_lines >=3: + self.set_prompt("Statements are terminated with a ';'. You can press CTRL-C to cancel an imcomplete statement.") + self.empty_lines = 0 + return if self.current_keyspace is None: self.set_prompt(self.continue_prompt) else: spaces = ' ' * len(str(self.current_keyspace)) self.set_prompt(self.keyspace_continue_prompt % spaces) + self.empty_lines += 1 @contextmanager def prepare_loop(self):