5 releases
0.1.4 | May 18, 2023 |
---|---|
0.1.3 | May 15, 2023 |
0.1.2 | May 14, 2023 |
0.1.1 | May 12, 2023 |
0.1.0 | May 12, 2023 |
#2306 in Command line utilities
37 downloads per month
21KB
468 lines
::: :::::::: :::::::: ::: ::::::::::: :+: :+: :+: :+: :+: :+: :+: +:+ +:+ +:+ +:+ +:+ +:+ +#+ +:+ +#+ +#+ +#+ +#+ +#+#+#+#+#+ +#+ +#+ +#+ +#+ #+# #+# #+# #+# #+# #+# ### ########## ######## ########## ###########
This is a simple CLI tool to manage, test and run your 42 projects.
Installation
Requirements
- Rust
- Norminette (Optional)
Install
From GitHub
cargo install --git https://github.com/herbievine/42-cli.git
From crates.io
cargo install ftcli
Setup alias
We recomment adding this line to your .bashrc
or .zshrc
to persist the ft
alias.
alias ft="ftcli"
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
name = "push_swap"
[scripts]
build = { cmd = "make" }
run = [
{ cmd = "./push_swap 8 2 -2 0 2147483647" },
{ cmd = "./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.
name = "so_long"
[scripts]
build = { cmd = "make", mlx = true, mlx_dir = "minilibx" }
run = [{ cmd = "./so_long maps/small.ber" }]
clean = { cmd = "make fclean", mlx = true, mlx_dir = "minilibx" }
lint = { cmd = "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:
name = "ft_printf"
[scripts]
build = { cmd = "make" }
test = [
{ cmd = "git clone https://github.com/Tripouille/printfTester.git tester" },
{ cmd = "make m", dir = "tester" },
{ cmd = "rm -rf tester" }
]
clean = { cmd = "make fclean" }
lint = { cmd = "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.
name = "42"
projects = [
"libft",
"ft_printf",
"get_next_line"
]
# Leave this empty
[scripts]
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.
ft help
build
Build your project with the defined build
scripts in the 42-cli.toml
file.
ft build
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.
ft run
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).
fourtytwo-cli test
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.
fourtytwo-cli clean
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.
fourtytwo-cli lint
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.
Dependencies
~1–12MB
~83K SLoC