def compose(*args, iterable=None):
    """
    Compose a full bytestring command from individual pieces.

    Args:
        *args: Variable list of command parts to combine. Arguments may be
            a bytes object, bytearay object, or an integer (which will be
            cast to a single byte).
        iterable: Any iterable object that yields objects compatible with the
            rules for `*args`

    Returns:
        bytearray: The fully composed command ready to be written to
        the output buffer.
    """
    buffer = bytearray()
    for obj in (iterable or args):
        if isinstance(obj, (bytes, bytearray)):
            buffer.extend(obj)
        elif isinstance(obj, (bool, int)):
            buffer.append(obj)
        elif obj is None:
            continue
        else:
            raise RuntimeError(f'Invalid object of type {type(obj)}')
    return buffer
