From c21dfb997e8af900cb35a39d1df8903a80dbaf5e Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Thu, 19 Jan 2023 14:57:39 -0500 Subject: [PATCH] Cleanup readme, add APIs to it --- README.md | 105 ++++++++++++++++++++++++++++++++++++++--------- lune.yml | 1 + luneTypes.d.luau | 2 + 3 files changed, 89 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7dae7e1..b19cfa0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ + + # Lune 🌙 [![CI](https://github.com/filiptibell/lune/actions/workflows/ci.yaml/badge.svg)](https://github.com/filiptibell/lune/actions/workflows/ci.yaml) @@ -11,9 +13,74 @@ A [Luau](https://luau-lang.org) script runner [Full example & walkthrough](.lune/hello_lune.luau) - +## ⚙️ Installation + +### Using [Aftman](https://github.com/lpghatguy/aftman) + +The preferred way of installing Lune. + +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 +``` + +### From [GitHub Releases](https://github.com/filiptibell/lune/releases) + +You can also download pre-built binaries for most systems directly from the linked GitHub Releases page. + +## ✏️ Writing Lune Scripts + +Check out the examples of how to write a script in the [.lune](.lune) folder ! +
-Example translation from Bash to Luau +🔎 Full list of APIs + +### **`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, +} +``` + +### **`json`** - JSON + +```lua +type json = { + encode: (value: any, pretty: boolean?) -> string, + decode: (encoded: string) -> any, +} +``` + +### **`process`** - Current process & child processes + +```lua +type process = { + getEnvVars: () -> { string }, + getEnvVar: (key: string) -> string?, + setEnvVar: (key: string, value: string) -> (), + exit: (code: number?) -> (), + spawn: (program: string, params: { string }?) -> { + ok: boolean, + code: number, + stdout: string, + stderr: string, + }, +} +``` + +
+ +
+🔀 Example translation from Bash to Luau **_Before:_** @@ -48,29 +115,30 @@ end
-## ⚙️ Installation +
+🧑‍💻 Configuring VSCode for Lune -### Using [Aftman](https://github.com/lpghatguy/aftman) +Lune puts developer experience first, and as such provides type definitions and configurations for several tools out of the box. -The preferred way of installing Lune. +
+Luau LSP -This will add `lune` to an `aftman.toml` file in the -current directory, or create one if it does not exist. +1. Use `lune --download-luau-types` to download Luau types (`luneTypes.d.luau`) to the current directory +2. Set your definition files setting to include `luneTypes.d.luau`, an example can be found in the [.vscode](.vscode) folder in this repository -```sh -$ aftman add filiptibell/lune -``` +
-### From [GitHub Releases](https://github.com/filiptibell/lune/releases) +
+Selene -You can also download pre-built binaries for most -systems directly from the linked GitHub Releases page. +1. Use `lune --download-selene-types` to download Selene types (`lune.yml`) to the current directory +2. Use either `std = "roblox-lune"` or `std = "luau+lune"` in your `selene.toml` configuration file -## ✏️ Writing Lune Scripts +
-First things first, check out the examples of how to write a script in the [.lune](.lune) folder!
-Lune has many useful built-in globals and APIs to use to interact with your system, and can do things -such as read/write files, run external programs, serialize & deserialize json, and much more. +**_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._ + +
## 🏃 Running Lune Scripts @@ -86,5 +154,4 @@ This will look for the script `script_name` in a few locations: - 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. +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. diff --git a/lune.yml b/lune.yml index 1bc8078..660f579 100644 --- a/lune.yml +++ b/lune.yml @@ -1,3 +1,4 @@ +# Lune v0.0.1 --- globals: # FS (filesystem) diff --git a/luneTypes.d.luau b/luneTypes.d.luau index 04abf5d..fcf69b1 100644 --- a/luneTypes.d.luau +++ b/luneTypes.d.luau @@ -1,3 +1,5 @@ +-- Lune v0.0.1 + declare fs: { readFile: (path: string) -> string, readDir: (path: string) -> { string },