summaryrefslogtreecommitdiffstats
path: root/iredis/bottom.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-21 10:28:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:16:53 +0000
commit06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch)
treee82f1bc439997ae296f2e74f8a64d84c5d95f140 /iredis/bottom.py
parentInitial commit. (diff)
downloadiredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz
iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iredis/bottom.py')
-rw-r--r--iredis/bottom.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/iredis/bottom.py b/iredis/bottom.py
new file mode 100644
index 0000000..28746f8
--- /dev/null
+++ b/iredis/bottom.py
@@ -0,0 +1,35 @@
+import logging
+from .commands import commands_summary
+from .utils import command_syntax
+
+BUTTOM_TEXT = "Ctrl-D to exit;"
+logger = logging.getLogger(__name__)
+
+
+class BottomToolbar:
+ CHAR = "⣾⣷⣯⣟⡿⢿⣻⣽"
+
+ def __init__(self, command_holder):
+ self.index = 0
+ # BottomToolbar can only read this variable
+ self.command_holder = command_holder
+
+ def get_animation_char(self):
+ animation = self.CHAR[self.index]
+
+ self.index += 1
+ if self.index == len(self.CHAR):
+ self.index = 0
+ return animation
+
+ def render(self):
+ text = BUTTOM_TEXT
+ # add command help if valide
+ if self.command_holder.command:
+ try:
+ command_info = commands_summary[self.command_holder.command]
+ text = command_syntax(self.command_holder.command, command_info)
+ except KeyError as e:
+ logger.exception(e)
+ pass
+ return text