# shellcheck shell=dash
___x_cmd_log_uirotate(){
    ___x_cmd_runmode_allow_manual || {
        ___x_cmd log :log error "UI rotate only support to be used in a interactive environments"
        return 1
    }
    local row=""
    local EXITCLEAR=""
    while [ $# -gt 0 ]; do
        case "$1" in
            -n)     row="$2";
                    [ $# -ge 2 ] || {
                        ___x_cmd log :log error "Require 1 argument after -n"
                        return 64
                    }
                    shift 2
                    ;;
            --clear-on-exit)
                    EXITCLEAR=1;
                    shift 1
                    ;;
            *)      break
        esac
    done

    ___x_cmd tty update
    if [ -z "$row" ]; then
        row="$(( LINES / 3 ))"
        [ "$row" -ge 5  ] || row=5
    fi

    ___x_cmd log :log info "UI rotate [row=$row] executing |"
    ___x_cmd ui rotate -n "$row" --prefix "${___X_CMD_LOG_YML_INDENT}    " ${EXITCLEAR:+--clear-on-exit} "$@"
}
