Parse the command input.

    Parameters
    ----------
    raw_command: str
        The raw command input, e.g., `register xxxxxx yyyyyy`.

    Returns
    -------
    arg_dict: dict(str, str or int)
        The parsed command output.
        {'command':'register', 'username': <username>, 'password': <password>} for `register`.
    Raises
    ------
    ValueError
        If the raw command can't be parsed correctly, e.g., it has an incorrect number of
        arguments or incorrect arguments.

def pytwis_command_parser(raw_command):
    """Parse the command input.

    Parameters
    ----------
    raw_command: str
        The raw command input, e.g., `register xxxxxx yyyyyy`.

    Returns
    -------
    arg_dict: dict(str, str or int)
        The parsed command output.
        {'command':'register', 'username': <username>, 'password': <password>} for `register`.
    Raises
    ------
    ValueError
        If the raw command can't be parsed correctly, e.g., it has an incorrect number of
        arguments or incorrect arguments.
    """
    validate_command(raw_command)

    # Some command (e.g., logout) may not have arguments.
    # Separate the command from its arguments.
    splited_raw_command = raw_command.split(' ', 1)

    arg_dict = {}

    if splited_raw_command[0] == pytwis_clt_constants.CMD_REGISTER:
        # register must have two arguments: username and password.
        args = splited_raw_command[1]

        arg_dict = parse.parse('{{{arg1}}} {{{arg2}}}'.\
                               format(arg1=pytwis_clt_constants.ARG_USERNAME,
                                      arg2=pytwis_clt_constants.ARG_PASSWORD),
                               args)
        if arg_dict is None:
            raise ValueError('{} has incorrect arguments'.format(pytwis_clt_constants.CMD_REGISTER))
        elif ' ' in arg_dict[pytwis_clt_constants.ARG_PASSWORD]:
            raise ValueError("password can't contain spaces")

        print('{}: username = {}, password = {}'.\
              format(pytwis_clt_constants.CMD_REGISTER,
                     arg_dict[pytwis_clt_constants.ARG_USERNAME],
                     arg_dict[pytwis_clt_constants.ARG_PASSWORD]))
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_LOGIN:
        # login must have two arguments: username and password.
        args = splited_raw_command[1]
        arg_dict = parse.parse('{{{arg1}}} {{{arg2}}}'.\
                               format(arg1=pytwis_clt_constants.ARG_USERNAME,
                                      arg2=pytwis_clt_constants.ARG_PASSWORD),
                               args)
        if arg_dict is None:
            raise ValueError('{} has incorrect arguments'.format(pytwis_clt_constants.CMD_LOGIN))

        print('{}: username = {}, password = {}'.\
              format(pytwis_clt_constants.CMD_LOGIN,
                     arg_dict[pytwis_clt_constants.ARG_USERNAME],
                     arg_dict[pytwis_clt_constants.ARG_PASSWORD]))
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_LOGOUT:
        # logout doesn't have any arguments.
        pass
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_CHANGE_PASSWORD:
        # changepwd must have three arguments: old_password, new_password, and
        # confirmed_new_password.
        args = splited_raw_command[1]
        arg_dict = parse.parse('{{{arg1}}} {{{arg2}}} {{{arg3}}}'.\
                               format(arg1=pytwis_clt_constants.ARG_OLD_PASSWORD,
                                      arg2=pytwis_clt_constants.ARG_NEW_PASSWORD,
                                      arg3=pytwis_clt_constants.ARG_CONFIRMED_NEW_PASSWORD),
                               args)
        if arg_dict is None:
            raise ValueError('{} has incorrect arguments'.\
                             format(pytwis_clt_constants.CMD_CHANGE_PASSWORD))
        elif arg_dict[pytwis_clt_constants.ARG_NEW_PASSWORD] !=\
            arg_dict[pytwis_clt_constants.ARG_CONFIRMED_NEW_PASSWORD]:
            raise ValueError('The confirmed new password is different from the new password')
        elif arg_dict[pytwis_clt_constants.ARG_NEW_PASSWORD] ==\
            arg_dict[pytwis_clt_constants.ARG_OLD_PASSWORD]:
            raise ValueError('The new password is the same as the old password')

        print('{}: old = {}, new = {}'.format(pytwis_clt_constants.CMD_CHANGE_PASSWORD,
                                              arg_dict[pytwis_clt_constants.ARG_OLD_PASSWORD],
                                              arg_dict[pytwis_clt_constants.ARG_NEW_PASSWORD]))
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_GET_USER_PROFILE:
        # userprofile doesn't have any arguments.
        pass
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_POST:
        # post must have one argument: tweet
        arg_dict = {pytwis_clt_constants.ARG_TWEET: splited_raw_command[1]}
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_FOLLOW:
        # follow must have one argument: followee.
        arg_dict = {pytwis_clt_constants.ARG_FOLLOWEE: splited_raw_command[1]}
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_UNFOLLOW:
        # unfollow must have one argument: followee.
        arg_dict = {pytwis_clt_constants.ARG_FOLLOWEE: splited_raw_command[1]}
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_GET_FOLLOWERS:
        # followers doesn't have any arguments.
        pass
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_GET_FOLLOWINGS:
        # followings doesn't have any arguments.
        pass
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_TIMELINE:
        # timeline has either zero or one argument.
        max_cnt_tweets = -1
        if len(splited_raw_command) >= 2:
            max_cnt_tweets = int(splited_raw_command[1])

        arg_dict = {pytwis_clt_constants.ARG_MAX_TWEETS: max_cnt_tweets}
    elif splited_raw_command[0] == pytwis_clt_constants.CMD_GET_USER_TWEETS:
        # tweetsby has either zero or one or two arguments.
        arg_dict = {pytwis_clt_constants.ARG_USERNAME: None,
                    pytwis_clt_constants.ARG_MAX_TWEETS: -1}

        if len(splited_raw_command) >= 2:
            # tweetsby has either one or two arguments.
            args = splited_raw_command[1]
            arg_dict = parse.parse('{{{arg1}}} {{{arg2}:d}}'.\
                                   format(arg1=pytwis_clt_constants.ARG_USERNAME,
                                          arg2=pytwis_clt_constants.ARG_MAX_TWEETS),
                                   args)
            if arg_dict is None:
                # tweetsby has only one argument.
                arg_dict = {pytwis_clt_constants.ARG_USERNAME: args}
                arg_dict[pytwis_clt_constants.ARG_MAX_TWEETS] = -1
    elif (splited_raw_command[0] == pytwis_clt_constants.CMD_EXIT) or\
        (splited_raw_command[0] == pytwis_clt_constants.CMD_QUIT):
        # exit or quit doesn't have any arguments.
        pass
    else:
        pass

    if isinstance(arg_dict, parse.Result):
        arg_dict = arg_dict.named
    arg_dict[pytwis_clt_constants.ARG_COMMAND] = splited_raw_command[0]

    return arg_dict