Helper coroutine to identify short options that haven't been used
    yet. Yields lists of short option (if available) and long option for
    the given name, keeping track of which short options have been previously
    used.

    If you aren't familiar with coroutines, use similar to a generator:
    x = generate_options()
    next(x)  # advance coroutine past its initialization code
    params = x.send(param_name)

def generate_options():
    '''Helper coroutine to identify short options that haven't been used
    yet. Yields lists of short option (if available) and long option for
    the given name, keeping track of which short options have been previously
    used.

    If you aren't familiar with coroutines, use similar to a generator:
    x = generate_options()
    next(x)  # advance coroutine past its initialization code
    params = x.send(param_name)
    '''
    used_short_options = set()
    param_name = yield
    while True:
        names = ['--' + param_name]
        for letter in param_name:
            if letter not in used_short_options:
                used_short_options.add(letter)
                names.insert(0, '-' + letter)
                break
        param_name = yield names