11from prompt_toolkit .buffer import Buffer
2-
3- from .commands import Command , UnsupportedCommand
2+ from .commands import UnsupportedCommand
43
54
65def 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-
2711class 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 ) + "> "
0 commit comments