mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Cleanup readme, add APIs to it
This commit is contained in:
parent
ebcbde8825
commit
c21dfb997e
3 changed files with 89 additions and 19 deletions
105
README.md
105
README.md
|
@ -1,3 +1,5 @@
|
|||
<!-- markdownlint-disable MD033 -->
|
||||
|
||||
# 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)
|
||||
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
## ⚙️ 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 !
|
||||
|
||||
<details>
|
||||
<summary>Example translation from Bash to Luau</summary>
|
||||
<summary><b>🔎 Full list of APIs</b></summary>
|
||||
|
||||
### **`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,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>🔀 Example translation from Bash to Luau</b></summary>
|
||||
|
||||
**_Before:_**
|
||||
|
||||
|
@ -48,29 +115,30 @@ end
|
|||
|
||||
</details>
|
||||
|
||||
## ⚙️ Installation
|
||||
<details>
|
||||
<summary><b>🧑💻 Configuring VSCode for Lune</b></summary>
|
||||
|
||||
### 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.
|
||||
<details>
|
||||
<summary>Luau LSP</summary>
|
||||
|
||||
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
|
||||
```
|
||||
</details>
|
||||
|
||||
### From [GitHub Releases](https://github.com/filiptibell/lune/releases)
|
||||
<details>
|
||||
<summary>Selene</summary>
|
||||
|
||||
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
|
||||
</details>
|
||||
|
||||
First things first, check out the examples of how to write a script in the [.lune](.lune) folder! <br>
|
||||
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._
|
||||
|
||||
</details>
|
||||
|
||||
## 🏃 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.
|
||||
|
|
1
lune.yml
1
lune.yml
|
@ -1,3 +1,4 @@
|
|||
# Lune v0.0.1
|
||||
---
|
||||
globals:
|
||||
# FS (filesystem)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
-- Lune v0.0.1
|
||||
|
||||
declare fs: {
|
||||
readFile: (path: string) -> string,
|
||||
readDir: (path: string) -> { string },
|
||||
|
|
Loading…
Reference in a new issue