add InegerTypeCompleter for bitfield.
@@ -48,6 +48,16 @@ class LatestUsedFirstWordCompleter(FuzzyWordCompleter):
self.touch(word)
+class IntegerTypeCompleter(LatestUsedFirstWordCompleter):
+ def __init__(self):
+ words = []
+ for i in range(1, 64):
+ words.append(f"i{i}") # signed integer, 64 bit max
+ words.append(f"u{i}") # unsigned integer, 63 bit max
+ words.append("i64")
+ super().__init__(len(words), words)
+
+
class TimestampCompleter(Completer):
"""
Completer for timestamp based on input.
@@ -122,6 +132,7 @@ def get_completer_mapping():
field_completer = LatestUsedFirstWordCompleter(config.completer_max, [])
group_completer = LatestUsedFirstWordCompleter(config.completer_max, [])
timestamp_completer = TimestampCompleter()
+ integer_type_completer = IntegerTypeCompleter()
completer_mapping.update(
{
@@ -140,6 +151,7 @@ def get_completer_mapping():
"group": group_completer,
# stream id
"stream_id": timestamp_completer,
+ "inttype": integer_type_completer,
}
)
# patch command completer with hint
@@ -185,7 +197,7 @@ class IRedisCompleter(Completer):
def get_completer(self, input_text):
try:
command, _ = split_command_args(input_text, all_commands)
- # compile grammar for this command
+ # here will compile grammar for this command
grammar = get_command_grammar(command)
completer = GrammarCompleter(
compiled_grammar=grammar, completers=self.completer_mapping
