def parse_command (command):
    """
        Parse rsync server command into bits.

            command:            - list(argv) including 'rsync' command and options/arguments

        Returns:
            cmd:        rsync argv[0]
            options:    list of --options and -opts
            paths:      list of path arguments

        Raises:
            CommandError

        >>> import shlex
        >>> parse_command(shlex.split('rsync --server --sender -ax . lvm:asdf:test'))
        ('rsync', ['--server', '--sender', '-ax'], ['.', 'lvm:asdf:test'])

    """

    cmd = None
    options = []
    paths = []

    # parse
    for part in command:
        if cmd is None:
            cmd = part

        elif part.startswith('--'):
            options.append(part)

        elif part.startswith('-'):
            # XXX: parse out individual flags..?
            options.append(part)

        else:
            paths.append(part)

    return cmd, options, paths