Skip to content

Commit fe86665

Browse files
committed
fix: update the tutorial to work with the latest Lux changes
1 parent ec803eb commit fe86665

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

docs/tutorial/03-creating-a-project.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Creating a Project
44
---
55

66
In the next chapters we will learn how to create, manage and publish a small Lua CLI
7-
that checks whether the entered words contain "hello" or not.
7+
that checks whether a sentence provided to the program contains the string "hello".
88
We will cover dependencies, the `lux.toml` format and more all the way up to API keys!
99

1010
To start writing Lua, we must initialize a project where we will store our code.
@@ -44,26 +44,35 @@ can be safely ignored.
4444
You'll see that our `my-lua-project/` directory was created. Let's enter the directory
4545
and get to work!
4646

47-
Inside of our project, you should see that a single file was generated:
47+
Inside of our project, you should see that a basic project skeleton was created:
4848

4949
```bash title="tree $(pwd)"
5050
/home/your-username/my-lua-project
51-
└── lux.toml
51+
├── lux.toml
52+
└── src
53+
└── main.lua
5254
```
5355

5456
The `lux.toml` file describes instructions on how to build and ship your Lua code.
5557
Let's enter the file. You should see contents similar to the following:
5658

57-
```lua title="lux.toml"
59+
```toml title="lux.toml"
5860
package = "my-lua-project"
5961
version = "0.1.0"
60-
lua = ">= 5.1"
62+
lua = ">=5.1"
6163

6264
[description]
6365
summary = "A sample project."
6466
maintainer = "vhyrro"
67+
labels = [ "learning" ]
6568
license = "MIT"
66-
labels = ["learning"]
69+
70+
[dependencies]
71+
# Add your dependencies here
72+
# `busted = ">=2.0"`
73+
74+
[run]
75+
args = [ "src/main.lua" ]
6776

6877
[build]
6978
type = "builtin"

docs/tutorial/04-adding-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This may take a while depending on your internet connection!
1919

2020
## Testing Our Changes
2121

22-
To check whether `argparse` is loaded we can enter a Lua REPL and play around
22+
To check whether `argparse` is loaded, we can enter a Lua REPL and play around
2323
with our code. However, just running `lua` will not work. To enter a
2424
`lua` REPL with our dependencies loaded, we need to run the following command instead:
2525

docs/tutorial/05-making-the-application.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,10 @@ id: making-the-application
33
title: Making the CLI Application
44
---
55

6-
Lux expects to find code under either a `src/` or `lua/` directory.
7-
For this series, we'll store our code under `src/`.
6+
## Creating the Skeleton
87

9-
Inside the project directory (where your `lux.toml` resides) create a `src/main.lua` file.
10-
This acts as the main file Lux will execute.
11-
12-
Here's what your project directory should look like after creating the file:
13-
```sh title="tree ."
14-
.
15-
├── lux.toml
16-
└── src
17-
└── main.lua
18-
19-
2 directories, 2 files
20-
```
21-
22-
## Ensuring the Project Runs
23-
24-
Let us add the following boilerplate code to `src/main.lua`:
8+
Let's add some simple boilerplate using `argparse`. This program will print back anything
9+
we pass as arguments back into the console:
2510

2611
```lua title="src/main.lua"
2712
local argparse = require("argparse")
@@ -36,10 +21,10 @@ local args = parser:parse()
3621
print(args.input)
3722
```
3823

39-
We're now ready to see if our code works! Run the following command to see your code in action:
24+
Run the following command to see your code in action:
4025

4126
```sh
42-
lux run "Testing our code!"
27+
lx run "Testing our code!"
4328
```
4429

4530
You should see `Testing our code!` printed right back at you in the console!

docs/tutorial/06-testing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ else
5252
end
5353
```
5454

55+
Noticed how we replaced the function with a `require` call to the new file.
56+
5557
## Writing our First Test
5658

5759
Now that we have our code structured, let's write our first test. Tests are usually stored in
@@ -81,7 +83,7 @@ end)
8183
## Running the Tests
8284

8385
We're now ready to run our tests! `lx test` will run all the tests in your
84-
project. After the automatic installation of `busted` you should see the following output:
86+
project. After taking a moment to install `busted`, Lux should show you the following output:
8587

8688
```sh title="lx test"
8789
●●

0 commit comments

Comments
 (0)