Creating a Project
In this chapter, we'll scaffold our project with lx new and take a first
look at the files it generates. Along the way we'll see how lux.toml ties
everything together.
To start, we'll initialize a project where we will store our code.
We'll do this in a my-lua-project/ directory.
To create a project, we can run:
lx new my-lua-project
We'll now be asked to provide information about our project so Lux can generate the appropriate skeleton code. Below is the output of the application, as well as the values we will provide. For the "Maintainer" field, feel free to provide your own name or username!
✔ Fetched remote repository metadata.
> Package name: my-lua-project
> Description: A sample project.
> License: MIT
> Labels: learning
> Maintainer: vhyrro
> What is the lowest Lua version you support? 5.1
Done!
Depending on the speed of your computer you may have noticed that we got a warning saying "could not fetch remote repo metadata" for a brief moment before disappearing and showing the prompts. This is not an issue, has no impact and can be safely ignored.
Exploring Our Project
You'll see that our my-lua-project/ directory was created. Let's enter the directory
and get to work!
Inside of our project, you should see that a basic project skeleton was created:
/home/your-username/my-lua-project
├── lux.toml
└── src
└── main.lua
Lux reads lux.toml to understand your project: its name, version,
dependencies, build instructions, and how to run it.
Let's enter the file. You should see contents similar to the following:
package = "my-lua-project"
version = "0.1.0"
lua = ">=5.1"
[description]
summary = "A sample project."
maintainer = "vhyrro"
labels = [ "learning" ]
license = "MIT"
[dependencies]
# Add your dependencies here
# `busted = ">=2.0"`
[run]
args = [ "src/main.lua" ]
[build]
type = "builtin"
Checking our Progress
To check whether our project was made successfully, first make sure you're in
the my-lua-project/ directory; afterwards, we can verify the project with:
lx debug project
This will show information about the project only if it was properly created. You should see the following output:
Project name: my-lua-project
Project version: 0.1.0-1
Project location: /home/your-username/my-lua-project
Congratulations! We're now ready to start adding some dependencies in the next chapter.