# shellcheck shell=sh disable=SC2034,SC2154,SC3043
# Section: ll zip file

# TODO: try to unified output format
___x_cmd_zuz_ll(){
    local target_file="${1:-filename}"; shift
    local ___X_CMD_ZUZ_NOT_UI=1
    case "$target_file" in
        *.tar)      LC_ALL="$___X_CMD_LOCALE_DEF_C" ___x_cmd_zuz_run tar -t <"$target_file" ;;  # bsdtar

        *.tar.bz2)  LC_ALL="$___X_CMD_LOCALE_DEF_C" ___x_cmd_zuz_run tar -t <"$target_file" ;;  # bsdtar
        *.tar.gz)   LC_ALL="$___X_CMD_LOCALE_DEF_C" ___x_cmd_zuz_run tar -t <"$target_file" ;;  # bsdtar
        *.tar.xz)   ___x_cmd_zuz_run ___x_cmd 7z l -ba "$target_file" | ___x_cmd_cmds_awk '{ print $NF }' ;;
        *.tar.zst)  ;;
        *.tar.Z)    LC_ALL="$___X_CMD_LOCALE_DEF_C" ___x_cmd_zuz_run tar -t <"$target_file" ;;  # bsdtar

        *.tgz)      LC_ALL="$___X_CMD_LOCALE_DEF_C" ___x_cmd_zuz_run tar -t <"$target_file" ;;  # bsdtar

        *.bz2|*.gz|*.xz|*.zst|.Z|*.rar)
                    zuz:error "Listing archive contents is not supported..">&2
                    return 1
                    ;;

        *.zip)      ___x_cmd_zuz_run ___x_cmd 7z l -ba "$target_file" ;; # bsdtar
        *.7z)       ___x_cmd_zuz_run ___x_cmd 7z l -ba "$target_file" | ___x_cmd_cmds_awk '{ print $NF }' ;;
        *)          ___x_cmd_zuz --help; zuz:warn "Unsupported to resolve as $target_file format.";
                    return 1
                    ;;
    esac
}
### EndSection

___x_cmd_zuz_show(){
    printf "%s\n" "x-cmd supports compression and decompression formats below"
    printf "%s\n" "compression: tar, tar.gz, tar.Z, tar.xz, tar.zst, gz, bz2, xz, tgz, zst, zip, rar, 7z, lha, lzh"
    printf "%s\n" "decompression: tar, tar.gz, tar.Z, tar.xz, tar.zst, tbz, gz, bz2, xz, tgz, zst, zip, rar, 7z, lha, lzh, Z"
}
