mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Print out the documentation for functions
This commit is contained in:
parent
e9338a84a3
commit
e4e9690e75
2 changed files with 22 additions and 1 deletions
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue