This is a simple CLI tool to manage, test and run your 42 projects.
Installation
Requirements
- Rust
- Norminette (Optional)
Install
From GitHub
From crates.io
Setup alias
We recomment adding this line to your .bashrc
or .zshrc
to persist the ft
alias.
Usage
When you have a config file present in your project, 42 CLI will attempt to run your command. There are a few speciad attributes which come with these commands, like installing MLX and executing a command in a specific directory.
Config file
You will need to create a 42-cli.toml
file in each of your projects. This file will look something like this:
# The name of the project
= "push_swap"
[]
= { = "make" }
= [
{ = "./push_swap 8 2 -2 0 2147483647" },
{ = "./push_swap invalid :(" },
]
Examples
Here, it is used in the so_long
project. Each script is defined by an object (except run
and test
which contain an array of objects) with special keys to automate your development.
= "so_long"
[]
= { = "make", = true, = "minilibx" }
= [{ = "./so_long maps/small.ber" }]
= { = "make fclean", = true, = "minilibx" }
= { = "norminette ." }
Here you have 4 scripts:
build
, which will runmake
after installing MLX in theminilibx
directory.run
, which will execute after runningbuild
(if present), and run./so_long maps/small.ber
(clean
can also be run at the end. See API Reference below)clean
, which will runmake fclean
, and then delete MLX.lint
, which simply runs norminette on your code.
Here is also an example with ft_printf
, which contains a test suite to execute:
= "ft_printf"
[]
= { = "make" }
= [
{ = "git clone https://github.com/Tripouille/printfTester.git tester" },
{ = "make m", = "tester" },
{ = "rm -rf tester" }
]
= { = "make fclean" }
= { = "norminette ." }
In this example, you will notice there is a test
script, which executes the defined scripts one-by-one. The test
script will execute the build
script, and run the clean
script after finishing (only if they are defined).
Usage in CI/CD
If you want to automate your deployements, or simply run commands on each of your projects in on command, you can create a config file in the head of your directory, like so:
42/
├─ libft/
│ ├─ 42-cli.toml
├─ ft_printf/
│ ├─ 42-cli.toml
├─ get_next_line/
│ ├─ 42-cli.toml
├─ 42-cli.toml
The root 42-cli.toml
file should contain a key called projects
, which all your projects defined as strings.
= "42"
= [
"libft",
"ft_printf",
"get_next_line"
]
# Leave this empty
[]
42 CLI will attempt to run your command in each of the defined projects, if it's not present, it will just skip it.
Note: the
run
command cannot be run as root.
API Reference
help
Displays the help menu.
build
Build your project with the defined build
scripts in the 42-cli.toml
file.
Options
-s, --silent
: Don't print the output of the build script.-h, --help
: Print help.
run
Run your project with the defined commands in the 42-cli.toml
file. It will first run the build
script if defined.
Options
-s, --silent
: Don't print the output of the run script.-c, --clean
: Run the clean script defined in the42-cli.toml
file.-h, --help
: Print help.
test
Run the test script defined in the 42-cli.toml
file. It will first run the build
script if defined, and run the clean
script once the test is done (even if it fails).
Options
-s, --silent
: Don't print the output of the test script.-h, --help
: Print help.
clean
Run the clean script defined in the 42-cli.toml
file.
Options
-s, --silent
: Don't print the output of the clean script.-h, --help
: Print help.
lint
Run the lint script defined in the 42-cli.toml
file.
Options
-s, --silent
: Don't print the output of the lint script.-h, --help
: Print help.
Support/Contributing
If you've found a bug or have a feature request, please open an issue. If you'd like to contribute, please open a pull request.