A standalone Luau runtime
Find a file
2023-02-23 11:31:42 +01:00
.github/workflows Fix workflow 2023-02-15 23:03:43 +01:00
.lune Improve websocket examples 2023-02-12 18:24:55 +01:00
.vscode Prepare for autogeneration of selene type definitions 2023-02-16 12:28:17 +01:00
docs Add support for query pairs in net.request params 2023-02-23 11:31:42 +01:00
packages Add support for query pairs in net.request params 2023-02-23 11:31:42 +01:00
tests Add support for query pairs in net.request params 2023-02-23 11:31:42 +01:00
.gitattributes Temporarily syntax highlight .luau files as normal lua 2023-01-23 20:55:43 -05:00
.gitignore Prepare for autogeneration of selene type definitions 2023-02-16 12:28:17 +01:00
.luaurc Initial commit 2023-01-18 20:47:14 -05:00
aftman.toml Remove tool used for testing 2023-02-16 12:50:56 +01:00
Cargo.lock De-UNC file paths on windows wherever possible 2023-02-22 23:21:37 +01:00
Cargo.toml Preserve order for json ser/de 2023-02-16 12:05:54 +01:00
CHANGELOG.md Implement API for moving / renaming files and / or directories 2023-02-23 00:00:48 +01:00
LICENSE.txt Add readme, license, cargo metadata 2023-01-18 21:19:10 -05:00
README.md Update configuration instructions in README 2023-02-15 23:28:08 +01:00
selene.toml Initial commit 2023-01-18 20:47:14 -05:00
stylua.toml Initial commit 2023-01-18 20:47:14 -05:00

Lune 🌙


A standalone
Luau script runner
🚀 Use the ergonomics and readability of Luau for your shell scripts 🚀

⚙️ Installation

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:

aftman add filiptibell/lune

You can also download pre-built binaries for most systems directly from the GitHub Releases page.

✏️ Writing Lune Scripts

A great starting point and walkthrough of Lune can be found in Hello, Lune.
More examples of how to write Lune scripts can be found in the examples folder.

🔎 List of APIs

fs - Filesystem
net - Networking
process - Current process & child processes
stdio - Standard input / output & utility functions
task - Task scheduler & thread spawning

Documentation for individual members and types can be found using your editor of choice and Luau LSP.

🔀 Example translation from Bash
#!/bin/bash
VALID=true
COUNT=1
while [ $VALID ]
do
    echo $COUNT
    if [ $COUNT -eq 5 ];
    then
        break
    fi
    ((COUNT++))
done

With Lune & Luau:

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.

These steps assume you have already installed Lune and that it is available to run in the current directory.

Luau LSP
  1. Run lune --generate-luau-types to generate a Luau type definitions file (luneTypes.d.luau) in the current directory

  2. Run lune --generate-docs-file to generate a Luau LSP documentation file (luneDocs.json) in the current directory

  3. Modify your VSCode settings, either by using the settings menu or in settings.json:

    {
    	"luau-lsp.require.mode": "relativeToFile", // Set the require mode to work with Lune
    	"luau-lsp.types.definitionFiles": ["luneTypes.d.luau"], // Add type definitions for Lune globals
    	"luau-lsp.types.documentationFiles": ["luneDocs.json"] // Add documentation for Lune globals
    }
    
Selene
  1. Run lune --generate-selene-types to generate a Selene type definitions file (lune.yml) in the current directory

  2. Modify your Selene settings in selene.toml:

    # Use this if Lune is the only thing you use Luau files with:
    std = "luau+lune"
    # OR use this if your project also contains Roblox-specific Luau code:
    std = "roblox+lune"
    # If you are also using the Luau type definitions file, it may cause issues, and can be safely ignored:
    exclude = ["luneTypes.d.luau"]
    

NOTE: It is highly recommended to add any generated files to your .gitignore and to only generate them using these commands, since this guarantees that you have type definitions compatible with your installed version of Lune.

🏃 Running Lune Scripts

After you've written a script file, for example script-name.luau, you can run it:

lune script-name

This will look for the file script-name.luau in a few locations:

  • The current directory
  • The folder lune in the current directory, if it exists
  • The folder .lune in the current directory, if it exists

If 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.

💭 Additional Commands

lune --list

Lists all scripts found in lune or .lune directories, including any top-level description comments.
Lune description comments are always written at the top of a file and start with a lua-style comment arrow (-->).


NOTE: Lune also supports files with the .lua extension but using the .luau extension is highly recommended.