
# shellcheck disable=SC2120

# show percentage count total info

# ___x_cmd_ourl_pbar --page 1-20

___x_cmd_ourl_pbar(){
    local size=0
    local total=
    local _cur=0

    local op=
    while op="$1"; do
        case "$op" in
            --total)    total="$2"
                        [ -n "$total" ] || N=ui M="Provide total value" log:ret:64
                        shift 2
                        ;;
            --size)     size="$2"
                        shift 2
                        ;;
            *)          break ;;
        esac
    done

    [ -n "$total" ] || N=ui M="Provide total value" log:ret:64

    local info; while read -r info; do
        _cur=$((_cur + 1))
        printf "%s\n" "$(( 100 * _cur / total ))"

        printf "%s\n" "count: ${_cur}/${total}"
        [ "$size" -le 0 ] || printf "%s\n" "$info"

        num="$((size - 1))"
        while [ "$num" -gt 0 ]; do
            read -r info
            printf "%s\n" "$info"
            num=$((num - 1))
        done
    done | x ui pbar --size "$((size + 2))"
}