Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 cc2f45237 -> 854aab79b
  refs/heads/trunk b281f33e4 -> bc9dc0f0a


(cqlsh) Display the current logged-in user

patch by Aaron Ploetz; reviewed by Mikhail Stepura for CASSANDRA-7785


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/854aab79
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/854aab79
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/854aab79

Branch: refs/heads/cassandra-2.1
Commit: 854aab79b7167cca29f237702ab92ba68fe56e08
Parents: cc2f452
Author: Aaron Ploetz <aaronplo...@gmail.com>
Authored: Thu Aug 21 15:34:46 2014 -0700
Committer: Mikhail Stepura <mish...@apache.org>
Committed: Thu Aug 21 19:57:20 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt |  1 +
 bin/cqlsh   | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/854aab79/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index fc6c942..5a1767a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.1
+ * (cqlsh) Display the current logged-in user (CASSANDRA-7785)
  * (cqlsh) Don't ignore CTRL-C during COPY FROM execution (CASSANDRA-7815)
  * (cqlsh) Order UDTs according to cross-type dependencies in DESCRIBE
    output (CASSANDRA-7659)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/854aab79/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 3fb972a..c055771 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -504,6 +504,7 @@ class Shell(cmd.Cmd):
             if not password:
                 password = getpass.getpass()
             self.auth_provider = PlainTextAuthProvider(username=username, 
password=password)
+        self.username = username
         self.keyspace = keyspace
         self.tracing_enabled = tracing_enabled
         self.expand_enabled = expand_enabled
@@ -712,9 +713,9 @@ class Shell(cmd.Cmd):
 
     def reset_prompt(self):
         if self.current_keyspace is None:
-            self.set_prompt(self.default_prompt)
+            self.set_prompt(self.default_prompt, True)
         else:
-            self.set_prompt(self.keyspace_prompt % self.current_keyspace)
+            self.set_prompt(self.keyspace_prompt % self.current_keyspace, True)
 
     def set_continue_prompt(self):
         if self.empty_lines >=3:
@@ -1062,7 +1063,10 @@ class Shell(cmd.Cmd):
         return cqlruleset.cql_complete(stuff_to_complete, text, 
cassandra_conn=self,
                                        debug=debug_completion, 
startsymbol='cqlshCommand')
 
-    def set_prompt(self, prompt):
+    def set_prompt(self, prompt, prepend_user=False):
+        if prepend_user and self.username:
+            self.prompt = "%s@%s" % (self.username, prompt)
+            return
         self.prompt = prompt
 
     def cql_unprotect_name(self, namestr):

Reply via email to