# shellcheck shell=dash

# Do you want to read the data from the pipe as example to deduce output.

xrc:mod:lib     jq     schema open repl fzf

___x_cmd_jq___main(){
    [ "$#" -gt 0 ] || {
        ___x_cmd_jq___cmd
        return
    }

    local op="$1"; shift
    case "$op" in
        -h|--help)  ___x_cmd help -m jq         "$@" ;;
        open)       ___x_cmd_jq_open            "$@" ;;
        r|repl)     ___x_cmd_jq_repl            "$@" ;;

        schema)     ___x_cmd_jq_schema          "$@" ;;

        --fzdata)   ___x_cmd_jq___fz_data       "$@" ;;
        # f|fzf)      ___x_cmd_jq_fzf             "$@" ;;
        # ,|--co)     ___x_cmd_jq_co              "$@" ;;

        --preparecmd)
                    ___x_cmd_jq___preparecmd    "$@" ;;
        --cmd)      ___x_cmd_jq___cmd           "$@" ;;
        *)          ___x_cmd_jq___cmd "$op"     "$@" ;;
    esac
}

___x_cmd_jq___cmd(){
    if ___x_cmd_hascmd jq; then
        ___x_cmd_jq___cmd(){
            ___x_cmd_cmds jq "$@"
        }
    else
        ___x_cmd_jq___cmd(){
            ___x_cmd snap --run jq "$@"
        }
    fi && ___x_cmd_jq___cmd "$@"
}

___x_cmd_jq___preparecmd(){
    ___x_cmd snap --preparecmd jq
}
