# shellcheck shell=dash

___x_cmd_lua_proj_init(){
    ___x_cmd luarocks init
    ___x_cmd mkdirp .x-cmd

    lua:info "Moving 'lua' and 'luarock' (generated by 'luarock init') to '.x-cmd/'"
    lua:info \
        --ref "https://x-cmd.com/start/lua"     \
        "Now you can use 'xw lua [...args]' or 'xw luarock[...args]' anywhere in the project folder"

    local bin_suffix=
    local x_; ___x_cmd os name_
    case "$___X_CMD_OS_NAME_" in
        win)    bin_suffix=.bat
    esac
    ___x_cmd_cmds mv "./lua${bin_suffix}" "./luarocks${bin_suffix}"     .x-cmd/


    lua:info "Generate .luarc so IDE can recognize this luarock project"

    # TODO: If already exists, we can modify it by just adding the workspace.library
    ___x_cmd_cmds cat >.luarc <<A
{
    "\$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
    "workspace.library": ["lua_modules/share"],
    "runtime.version": "Lua 5.4",
    "hint.enable": false
}
A

}
