INNER CODE UNIT · Python
dot_help
probcomp/bayeslite · shell/src/core.py:151
def dot_help(self, line):
'''show help for commands
[<cmd> ...]
Show help for commands. With no arguments, list all commands.
'''
tokens = line.split()
if len(tokens) == 0:
pad = max(1 + len(cmd) for cmd in self._cmds)
for cmnd in sorted(self._cmds):
method = getattr(self, 'do_.%s' % (cmnd,))
if method.__doc__ is not None:
doc = [l.strip() for l in method.__doc__.splitlines()]
else:
doc = ['', '']
assert 1 < len(doc)
self.stdout.write(' %*s %s\n' % (pad, '.' + cmnd, doc[0]))
self.stdout.write('Type `.help <cmd>\''