# shellcheck shell=dash

xrc:mod:lib     cmdnotfound         init

___x_cmd_cmdnotfound___main(){
    local op="$1";
    case "$op" in
        enable|disable|enabled)
            shift; "___x_cmd_cmdnotfound_${op}" "$@" ;;
        -h|--help|*)  x help -m cmdnotfound >&2; return 1 ;;
    esac
}


___x_cmd_cmdnotfound_enable(){
    ___x_cmd_cmdnotfound_init
}

___x_cmd_cmdnotfound_enabled(){
    case "${___X_CMD_SHELL}" in
        zsh)
            x runnable command_not_found_handler ;;
        bash)
            x runnable command_not_found_handle ;;
        *)
            # Ask the user to use repl
            return 1
    esac
}

___x_cmd_cmdnotfound_disable(){
    case "${___X_CMD_SHELL}" in
        zsh)
            unset -f command_not_found_handler ;;
        bash)
            unset -f command_not_found_handle ;;
        *)
            # Ask the user to use repl
    esac
}

