
# shellcheck shell=dash disable=SC2154

___x_cmd_zig_target_all(){
    [ "$#" -gt 0 ] ||   set -- --nv
    local op="$1"; shift
    case "$op" in
        --nv|--app|--json|--yml)  ___x_cmd_zig_target_all___"${op#*--}"   ;;
    esac
}

___x_cmd_zig_target_all___nv(){
    if ___x_cmd_is_stdout2tty; then
        ___x_cmd_zig_target_all___app
        return
    fi

    ___x_cmd_zig_target_all___json
}

___x_cmd_zig_target_all___app(){
    local ___X_CMD_JO_NAV_FINAL_COMMAND=
    local ___X_CMD_JO_NAV_KP=
    local ___X_CMD_JO_NAV_VALUE=
    local target_data="$(___x_cmd_zig_target_all___json)"
    [ -n "$target_data" ] || return 1
    printf "%s\n" "$target_data" | x jo .native | {
        x jo env . os=.os abi=.abi triple=.triple arch=.cpu.arch
        zig:info \
            --os "$os" --arch "$arch" --abi "$abi" --triple "$triple" \
            "Current host information"
    }
    x jo nav -- printf "%s\n" "$target_data"
}

___x_cmd_zig_target_all___json(){
    ___x_cmd_zig___command targets || N="zig" M="list target fail" log:ret:1
}

___x_cmd_zig_target_all___yml(){
    ___x_cmd_zig_target_all___json | x j2y
}
