You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for multi-file CLI command scripts embedded into the lute executable (#314)
## Summary
In this PR, we add support for running command-line Luau scripts that
are stored in the `cli/commands` directory.
If we have `cli/commands/foo.luau` or `cli/commands/foo/init.luau`,
running `lute foo` will automatically execute the contents of that
script (with support for relative requires as well).
## Implementation details
We create a new `CliVfs` that is optionally be embedded in `RequireVfs`.
The CLI enables this, but `vm.create` does not, as it does not need a
custom VFS for command-line scripts. The actual implementation of the
VFS is nearly identical to `StdLibVfs`.
The embedding of the CLI scripts is done using Luthier to generate
source files for a new `Lute.CLI.Commands` target. This is similar to
how the `@std` libraries were embedded into the `Lute.Std` target.
- #138
- #205
While working on this, I noticed that `luthier.luau` was incomplete. Due
to the lack of an `os.walk` API like we have in Python, `luthier.luau`
doesn't correctly handle nested directories that need to be embedded. To
solve this, I have added a `traverseFileTree` function that effectively
accomplishes the same thing.
Because of slight differences in the order files are processed by
`os.walk` and `traverseFileTree`, `luthier.py` and `luthier.luau` spit
out different hashes. I think this is fine. When only using one of the
tools in isolation, the caching seems to work as expected.
0 commit comments