# shellcheck    shell=dash
# TODO: In the future ... rust/zig => wasm ...

xrc node

___x_cmd_jsch_to(){
    local op="$1";

    case "$op" in
        *.json)
            case "$2" in
                *.ts)       ___x_cmd_jsch_to_tstype "$@" ;;
                *.py)       ___x_cmd_jsch_to_python "$@" ;;
                *.java)     ___x_cmd_jsch_to_java "$@" ;;
                *.go)       ___x_cmd_jsch_to_go "$@" ;;
                *.rb)       ___x_cmd_jsch_to_ruby "$@" ;;
                *)          echo "Not Implemented." >/dev/stderr
            esac
            return
            ;;
        *)          ;;
    esac

    if command -v "___x_cmd_jsch_to_$op" 2>/dev/null; then
        shift 1
        "___x_cmd_jsch_to_$op" "$@"
        return
    fi

    echo "Provide Help" >/dev/stderr
    return 1
}


___x_cmd_jsch_to_tstype(){
    if ! command -v json2ts 1>/dev/null 2>&1; then
        ___x_cmd_npm install -g "json-schema-to-typescript"
    fi

    json2ts -i "${1:?Provice schema}" -o "${2:?Provide typefile}"
    # x npx @xcmd/jsch tstype "$@"
}

___x_cmd_jsch_to_java(){
    x npx @xcmd/jsch java "$@"
}

___x_cmd_jsch_to_python(){
    x npx @xcmd/jsch python "$@"
}

___x_cmd_jsch_to_ruby(){
    x npx @xcmd/jsch ruby "$@"
}

___x_cmd_jsch_to_go(){
    x npx @xcmd/jsch go "$@"
}
