# shellcheck shell=dash

___x_cmd_lua_proj___initifnull_(){
    ! ___x_cmd locatefolder_ . lua_modules || return 0

    ___x_cmd_runmode_allow_manual || N=lua M="Abort because No lua_modules found" log:ret:1

    local id

    lua:info "No lua_modules found in current directory and parent directories"

    ! ___x_cmd locatefolder_ . .x-cmd || {
        lua:info "We found .x-cmd directory in $x_"

        ___x_cmd ui select id  "What's next:" \
            "Init the luarock project in $x_"       \
            "Init the luarock project in current directory -> $PWD"      \
            "ABORT"
        case "$id" in
            1)
                (
                    ___x_cmd_inner_cd "$x_"
                    ___x_cmd_lua rock init
                )
                ;;
            2)  x_="$PWD"
                ___x_cmd_lua rock init  ;;
            # TODO: pick up a folder to initialize
            *)  return 1
        esac
        return
    }

    ___x_cmd ui select id  \
        "Init the luarock project in current directory -> $PWD"      \
        ABORT

    case "$id" in
        2)  x_="$PWD"
            ___x_cmd_lua rock init  ;;
        # TODO: pick up a folder to initialize
        *)  return 1
    esac
}
