Print out the documentation for functions

This commit is contained in:
Thomas S Hatch 2011-03-14 14:34:02 -06:00
parent e9338a84a3
commit e4e9690e75
2 changed files with 22 additions and 1 deletions

View file

@ -83,5 +83,25 @@ class SaltCMD(object):
]
if self.opts['pcre']:
args.append('pcre')
print local.cmd(*args)
ret = local.cmd(*args)
# Handle special case commands
if self.opts['fun'] == 'sys.cmd':
self._print_docs(ret)
else:
print ret
def print_docs(self, ret):
'''
Print out the docstrings for all of the functions on the minions
'''
docs = {}
for host in ret:
for fun in ret['host']:
if not docs.has_key(fun):
docs[fun] = ret[host][fun].__doc__
for fun in docs:
print fun
print docs[fun]

View file

@ -64,6 +64,7 @@ class Minion(object):
if callable(getattr(module, attr)):
functions[mod + '.' + attr] = getattr(module, attr)
functions['sys.list_functions'] = lambda: functions.keys()
functions['sys.doc'] = lambda: functions
print functions
return functions