'''
The sys module provides information about the available functions on the
minion.
'''

def __virtual__():
    '''
    Return as sys
    '''
    return 'sys'


def doc(module=''):
    '''
    Return the docstrings for all modules, these strings are aggregated into
    a single document on the master for easy reading.

    CLI Example::

        salt \* sys.doc
    '''
    docs = {}
    for fun in __salt__:
        if fun.startswith(module):
            docs[fun] = __salt__[fun].__doc__
    return docs


def list_functions(module=''):
    '''
    List the functions.  Optionally, specify a module to list from.

    CLI Example::

        salt \* sys.list_functions
    '''
    names = set()
    for func in __salt__:
        if module:
            if func.startswith('{0}.'.format(module)):
                names.add(func)
        else:
            names.add(func)
    return sorted(names)


def list_modules():
    '''
    List the modules loaded on the minion

    CLI Example::

        salt \* sys.list_modules
    '''
    modules = set()
    for func in __salt__:
        comps = func.split('.')
        if len(comps) < 2:
            continue
        modules.add(comps[0])
    return sorted(modules)


def reload_modules():
    '''
    Tell the minion to reload the execution modules

    CLI Example::

        salt \* sys.reload_modules
    '''
    # This is handled inside the minion.py file, the function is caught before
    # it ever gets here
    return True

@@ -228,14 +228,88 @@
 ules
-, thes
+. Optionally, specify a module or a%0A    function to narrow te selection.%0A%0A    Th
 e st
@@ -333,20 +333,16 @@
 ted into
-%0A   
  a singl
@@ -374,16 +374,20 @@
 for easy
+%0A   
  reading
@@ -440,25 +440,261 @@
     
-'''%0A    docs = %7B%7D
+    salt %5C* sys.doc sys%0A        salt %5C* sys.doc sys.doc%0A    '''%0A    docs = %7B%7D%0A    if module:%0A        # allow both %22sys%22 and %22sys.%22 to match sys, without also matching%0A        # sysctl%0A        module = module + '.' if not module.endswith('.') else module
 %0A   
@@ -875,18 +875,33 @@
 unctions
-.
  
+for all modules.
  Optiona
@@ -929,16 +929,20 @@
  to list
+%0A   
  from.%0A%0A
@@ -1003,174 +1003,305 @@
     
-'''%0A    names = set()%0A    for func in __salt__:%0A        if module:%0A            if func.startswith('%7B0%7D.'.format(
+    salt %5C* sys.list_functions sys%0A    '''%0A    names = set()%0A    if module:%0A        # allow both %22sys%22 and %22sys.%22 to match sys, without also matching%0A        # sysctl%0A        module = module + '.' if not module.endswith('.') else 
 module
-)):
 %0A    
-            names.add(func)%0A        else
+for func in __salt__:%0A        if func.startswith(module)
 :%0A  

Allow matching of the sys module without also matching sysctl.