.. versionadded:: 2015.5.0

    Display all matching rules as specified by name

    Args:
        name (Optional[str]): The full name of the rule. ``all`` will return all
            rules. Default is ``all``

    Returns:
        dict: A dictionary of all rules or rules that match the name exactly

    Raises:
        CommandExecutionError: If the command fails

    CLI Example:

    .. code-block:: bash

        salt '*' firewall.get_rule 'MyAppPort'

def get_rule(name='all'):
    '''
    .. versionadded:: 2015.5.0

    Display all matching rules as specified by name

    Args:
        name (Optional[str]): The full name of the rule. ``all`` will return all
            rules. Default is ``all``

    Returns:
        dict: A dictionary of all rules or rules that match the name exactly

    Raises:
        CommandExecutionError: If the command fails

    CLI Example:

    .. code-block:: bash

        salt '*' firewall.get_rule 'MyAppPort'
    '''
    cmd = ['netsh', 'advfirewall', 'firewall', 'show', 'rule',
           'name={0}'.format(name)]
    ret = __salt__['cmd.run_all'](cmd, python_shell=False, ignore_retcode=True)
    if ret['retcode'] != 0:
        raise CommandExecutionError(ret['stdout'])

    return {name: ret['stdout']}