@@ -278,42 +278,34 @@ def _process_command(self, command: str) -> None:
278278 cmd = parts [0 ].lower () if parts else ""
279279 args = parts [1 :] if len (parts ) > 1 else []
280280
281- match cmd :
282- case "?" | "help" :
283- self ._show_help ()
284- case "apps" :
285- self ._cmd_apps ()
286- case "app" :
287- if args :
288- self ._cmd_app_detail (args [0 ])
289- else :
290- self ._add_error_message ("Usage: app <name>" )
291- case "start" :
292- if args :
293- self ._cmd_start (args [0 ])
294- else :
295- self ._add_error_message ("Usage: start <app_name>" )
296- case "stop" :
297- if args :
298- self ._cmd_stop (args [0 ])
299- else :
300- self ._add_error_message ("Usage: stop <app_name>" )
301- case "restart" :
302- if args :
303- self ._cmd_restart (args [0 ])
304- else :
305- self ._add_error_message ("Usage: restart <app_name>" )
306- case "logs" :
307- if args :
308- self ._cmd_logs (args [0 ])
309- else :
310- self ._add_error_message ("Usage: logs <app_name>" )
311- case "status" :
312- self ._cmd_status ()
313- case "clear" :
314- self ._cmd_clear ()
315- case _:
316- self ._add_error_message (f"Unknown command: { cmd } \n Type ? for help" )
281+ # Commands that don't require arguments
282+ simple_commands = {
283+ "?" : self ._show_help ,
284+ "help" : self ._show_help ,
285+ "apps" : self ._cmd_apps ,
286+ "status" : self ._cmd_status ,
287+ "clear" : self ._cmd_clear ,
288+ }
289+
290+ # Commands that require an app name argument
291+ app_commands = {
292+ "app" : (self ._cmd_app_detail , "app <name>" ),
293+ "start" : (self ._cmd_start , "start <app_name>" ),
294+ "stop" : (self ._cmd_stop , "stop <app_name>" ),
295+ "restart" : (self ._cmd_restart , "restart <app_name>" ),
296+ "logs" : (self ._cmd_logs , "logs <app_name>" ),
297+ }
298+
299+ if cmd in simple_commands :
300+ simple_commands [cmd ]()
301+ elif cmd in app_commands :
302+ handler , usage = app_commands [cmd ]
303+ if args :
304+ handler (args [0 ])
305+ else :
306+ self ._add_error_message (f"Usage: { usage } " )
307+ else :
308+ self ._add_error_message (f"Unknown command: { cmd } \n Type ? for help" )
317309
318310 def _show_help (self ) -> None :
319311 """Show help message."""
0 commit comments