def parse_command_result(res, label=None):
    '''
    Parse the result of a zpool/zfs command

    .. note::

        Output on failure is rather predicatable.
        - retcode > 0
        - each 'error' is a line on stderr
        - optional 'Usage:' block under those with hits

        We simple check those and return a OrderedDict were
        we set label = True|False and error = error_messages

    '''
    ret = OrderedDict()

    if label:
        ret[label] = res['retcode'] == 0

    if res['retcode'] != 0:
        ret['error'] = []
        for error in res['stderr'].splitlines():
            if error.lower().startswith('usage:'):
                break
            if error.lower().startswith("use '-f'"):
                error = error.replace('-f', 'force=True')
            if error.lower().startswith("use '-r'"):
                error = error.replace('-r', 'recursive=True')
            ret['error'].append(error)

        if ret['error']:
            ret['error'] = "\n".join(ret['error'])
        else:
            del ret['error']

    return ret
Parse the result of a zpool/zfs command

    .. note::

        Output on failure is rather predicatable.
        - retcode > 0
        - each 'error' is a line on stderr
        - optional 'Usage:' block under those with hits

        We simple check those and return a OrderedDict were
        we set label = True|False and error = error_messages