def _step_02_command_simple_validate()

in atr/ssh.py [0:0]


def _step_02_command_simple_validate(argv: list[str]) -> tuple[str | None, int, bool]:
    """Validate the basic structure of the rsync command and detect read vs write."""
    # READ: ['rsync', '--server', '--sender', '-vlogDtpre.iLsfxCIvu', '.', '/proj/v1/']
    # WRITE: ['rsync', '--server', '-vlogDtpre.iLsfxCIvu', '.', '/proj/v1/']

    if not argv:
        return "Empty command", -1, False

    if argv[0] != "rsync":
        return "The first argument must be rsync", -1, False

    if argv[1] != "--server":
        return "The second argument must be --server", -1, False

    is_read_request = False
    option_index = 2

    # Check for --sender flag, which indicates a read request
    if (len(argv) > 2) and (argv[2] == "--sender"):
        is_read_request = True
        option_index = 3
        if len(argv) <= option_index:
            return "Missing options after --sender", -1, True
    elif len(argv) <= 2:
        return "Missing options argument", -1, False

    # Validate the options argument strictly
    options = argv[option_index]
    if "e." not in options:
        return "The options argument (after --sender) must contain 'e.'", -1, True
    # The options after -e. are compatibility flags and can be ignored
    if options.split("e.", 1)[0] != "-vlogDtpr":
        return "The options argument (after --sender) must be '-vlogDtpre.[compatibility flags]'", -1, True

    ####################################################
    ### Calls _step_03_validate_rsync_args_structure ###
    ####################################################
    error, path_index = _step_03_validate_rsync_args_structure(argv, option_index, is_read_request)
    if error:
        return error, -1, is_read_request

    return None, path_index, is_read_request