Skip to content

Commit b5a1155

Browse files
committed
docs(examples): add set_paths.lua helper and update example usage documentation
1 parent 80a46ca commit b5a1155

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ root:parse({"remove", "2"})
6565

6666
See other examples in the [`examples/`](examples/) directory.
6767

68+
> Use [`set_paths.lua`](set_paths.lua) to run examples locally:
69+
>
70+
> ```
71+
> lua -l set_paths examples/basic_usage.lua
72+
> ```
73+
6874
## Attribution
6975
7076
If you create a new project based substantially on this CLI library, please
@@ -80,3 +86,4 @@ Copyright © 2025 github.com/toasted323
8086
8187
This project is licensed under the MIT License.
8288
See [LICENSE](LICENSE) in the root of this repository for full details.
89+
```

set_paths.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
local base_path = os.getenv("BASE_PATH") or "./"
2+
local lua_version = "5.1"
3+
local path_sep = package.config and package.config:sub(3,3) or ';'
4+
5+
package.path = table.concat({
6+
base_path .. "/src/?.lua",
7+
base_path .. "/src/?/init.lua",
8+
base_path .. "/lua_modules/share/lua/" .. lua_version .. "/?.lua",
9+
base_path .. "/lua_modules/share/lua/" .. lua_version .. "/?/init.lua",
10+
package.path
11+
}, path_sep)
12+
13+
package.cpath = table.concat({
14+
base_path .. "/lua_modules/lib/lua/" .. lua_version .. "/?.so",
15+
package.cpath
16+
}, path_sep)
17+
18+
return true

0 commit comments

Comments
 (0)