Skip to content

Commit dbeb99a

Browse files
author
Seth Rider
committed
Can now look up the word: 'help' in dictionaries
1 parent 0263a49 commit dbeb99a

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

plover_console_ui/commander.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from prompt_toolkit.buffer import Buffer
2-
3-
from .commands import Command, UnsupportedCommand
2+
from .commands import UnsupportedCommand
43

54

65
def peek(list):
@@ -9,28 +8,12 @@ def peek(list):
98
return None
109

1110

12-
class Help(Command):
13-
def __init__(self, commander) -> None:
14-
self.commander = commander
15-
super().__init__("help", commander.output)
16-
17-
def handle(self, words=None):
18-
handler = self.commander.current_handler()
19-
handler.describe()
20-
return True
21-
22-
23-
def build_meta_commands(commander):
24-
return [Help(commander)]
25-
26-
2711
class Commander:
2812
def __init__(self, top_command, output) -> None:
2913
self.top_command = top_command
3014
self.output = output
3115
self.on_exit_state = None
3216
self.state = []
33-
self.meta_commands = build_meta_commands(self)
3417

3518
def __call__(self, buff: Buffer):
3619
try:
@@ -75,9 +58,6 @@ def handle_command(self, words):
7558
self.state.pop()
7659
return
7760

78-
if self.handled_meta_command(words):
79-
return
80-
8161
local_state = self.state[:]
8262
handler = self.current_handler()
8363

@@ -99,13 +79,5 @@ def handle_command(self, words):
9979
if not handler.handle(words):
10080
self.state = local_state
10181

102-
def handled_meta_command(self, words):
103-
possible_meta = peek(words)
104-
for meta in self.meta_commands:
105-
if meta.name.lower().startswith(possible_meta.lower()):
106-
meta.handle(words)
107-
return True
108-
return False
109-
11082
def prompt(self):
11183
return " ".join(self.state) + "> "

plover_console_ui/commands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def sub_commands(self):
2929

3030
def handle(self, words=[]):
3131
if words:
32+
if words[0].lower().startswith("help"):
33+
self.describe()
34+
return True
3235
raise UnsupportedCommand()
3336
else:
3437
self.describe()

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = plover_console_ui
3-
version = 1.1.0
3+
version = 1.1.1
44
description = Text User Interface for Plover
55
long_description = file: README.rst
66
author = Seth Rider

0 commit comments

Comments
 (0)