A standalone Luau script runner
🚀 Use the ergonomics and readability of Luau instead of shell scripts 🚀
The preferred way of installing Lune is using Aftman.
This will add lune
to an aftman.toml
file in the current directory, or create one if it does not exist:
sh
aftman add filiptibell/lune
You can also download pre-built binaries for most systems directly from the GitHub Releases page.
Check out the examples of how to write a script in the .lune folder !
🔎 Full list of APIs
console - Logging & formatting
lua
type console = {
resetColor: () -> (),
setColor: (color: "black" | "red" | "green" | "yellow" | "blue" | "purple" | "cyan" | "white") -> (),
resetStyle: () -> (),
setStyle: (color: "bold" | "dim") -> (),
format: (...any) -> (string),
log: (...any) -> (),
info: (...any) -> (),
warn: (...any) -> (),
error: (...any) -> (),
}
fs - Filesystem
lua
type fs = {
readFile: (path: string) -> string,
readDir: (path: string) -> { string },
writeFile: (path: string, contents: string) -> (),
writeDir: (path: string) -> (),
removeFile: (path: string) -> (),
removeDir: (path: string) -> (),
isFile: (path: string) -> boolean,
isDir: (path: string) -> boolean,
}
net - Networking
lua
type net = {
request: (config: string | {
url: string,
method: ("GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "PATCH")?,
headers: { [string]: string }?,
body: string?,
}) -> {
ok: boolean,
statusCode: number,
statusMessage: string,
headers: { [string]: string },
body: string,
},
jsonEncode: (value: any, pretty: boolean?) -> string,
jsonDecode: (encoded: string) -> any,
}
process - Current process & child processes
lua
type process = {
args: { string },
env: { [string]: string? },
exit: (code: number?) -> (),
spawn: (program: string, params: { string }?) -> {
ok: boolean,
code: number,
stdout: string,
stderr: string,
},
}
task - Task scheduler & thread spawning
lua
type task = {
cancel: (thread: thread) -> (),
defer: <T...>(functionOrThread: thread | (T...) -> (...any), T...) -> thread,
delay: <T...>(duration: number?, functionOrThread: thread | (T...) -> (...any), T...) -> thread,
spawn: <T...>(functionOrThread: thread | (T...) -> (...any), T...) -> thread,
wait: (duration: number?) -> (number),
}
🔀 Example translation from Bash
```bash
VALID=true COUNT=1 while [ $VALID ] do echo $COUNT if [ $COUNT -eq 5 ]; then break fi ((COUNT++)) done ```
With Lune & Luau:
lua
local valid = true
local count = 1
while valid do
print(count)
if count == 5 then
break
end
count += 1
end
🧑💻 Configuring VSCode for Lune
Lune puts developer experience first, and as such provides type definitions and configurations for several tools out of the box.
Luau LSP
lune --download-luau-types
to download Luau types (luneTypes.d.luau
) to the current directoryluneTypes.d.luau
relativeToFile
An example of these settings can be found in the .vscode folder in this repository
lune --download-selene-types
to download Selene types (lune.yml
) to the current directorystd = "luau+lune"
, or std = "roblox+lune"
if your project also contains Roblox-specific code, in your selene.toml
configuration file
NOTE: It is highly recommended to add any type definition files to your .gitignore
and to only download them using these commands, since this guarantees that you have type definitions compatible with your installed version of Lune.
After you've written a script file, for example script-name.luau
, you can run it:
sh
lune script-name
This will look for the file script-name.luau
in a few locations:
lune
in the current directory, if it exists.lune
in the current directory, if it existsIf you don't want Lune to look in sub-directories you can provide a full file path with the file extension included, instead of only the file name.
NOTE: Lune also supports files with the .lua
extension but using the .luau
extension is highly recommended.