if alert:
self._log.alert(f'invalid prompt command: {alert}')
+ def cmd__help(self) -> None:
+ 'Print available commands.'
+ self._log.add('commands available in this window:')
+ cmds = {}
+ cmd_prefix = 'cmd__'
+ base = 'self'
+ for path in (base, f'{base}.window', f'{base}.window.prompt'):
+ for cmd_method_name in [attr_name for attr_name in dir(eval(path))
+ if attr_name.startswith(cmd_prefix)]:
+ path_prefix = f'{path}.'
+ cmd_name = (path_prefix[len(base)+1:]
+ + cmd_method_name[len(cmd_prefix):])
+ method = eval(f'{path_prefix}{cmd_method_name}')
+ args = []
+ for key, param in signature(method).parameters.items():
+ arg = key.upper()
+ if param.default != inspect_empty:
+ arg = f'[{arg}]'
+ args += [arg]
+ cmds[cmd_name] = args
+ to_log = []
+ for cmd_name, args in cmds.items():
+ for key, target in CMD_SHORTCUTS.items():
+ if target == cmd_name:
+ cmd_name = key
+ to_log += [f'{cmd_name} {" ".join(args)}']
+ for item in sorted(to_log):
+ self._log.add(f' /{item}')
+
def cmd__quit(self) -> None:
'Trigger program exit.'
self._put(QuitEvent())