# shellcheck shell=dash

___x_cmd_tz_ls(){
    [ "$#" -gt 0 ] ||   set -- --tsv

    local op="$1"; shift
    case "$op" in
        --raw|--csv|--tsv)
            ___x_cmd_tz_ls___"${op#--}" "$@"
            ;;
        *)
            N=tz M="Unknown subcmd -> $op" log:ret:64
            ;;

    esac
}

___x_cmd_tz_ls___csv(){
    ___x_cmd_tz_ls___raw | ___x_cmd_cmds awk '{
        printf("%s,%s,%s\n", $1, $2, $4)
    }'
}

___x_cmd_tz_ls___tsv(){
    local NO_COLOR="$NO_COLOR"
    ___x_cmd_is_stdout2tty || NO_COLOR=1
    if [ "$NO_COLOR" = "1" ];then
        ___x_cmd_tz_ls___csv | ___x_cmd csv static_tab
    else
        ___x_cmd_tz_ls___tsv_colored
    fi
}

___x_cmd_tz_ls___tsv_colored(){
    ___x_cmd_tz_ls___csv | ___x_cmd csv static_tab --color auto
}

___x_cmd_tz_ls___raw(){
    ___x_cmd_tz___run -list
}
