Initialization
Learn how to interact with the CLI
Initialization
To use the CLI, you can execute it directly within the latest version:
Guide
At first, you must initialize the Rehooks configuration. To do this, run the following command into your project's directory:
You'll be prompted to choose a path for the hooks to be imported. If you want use a custom path for the hooks directory, you can pass it as an argument to the init command.
Rehooks requires React version 18 or higher. If your project uses a lower
version, you will encounter compatibility issues. Also your project must
include package.json file.
Now It's time to import hooks into your project. To achieve this you must run the add command.
This command will ask you to select the hooks you want to import from the list of available hooks through the API. You can select multiple hooks by pressing the space key.
You can pick hooks up to 10 at a time, due to the limitation of the API.
If you want to pass hooks manually, you can do so by running the following command:
List
To list all available hooks in the API, you can run the following command:
The result will be displayed in the terminal with the description of each hook.
Options
These are the options available in the CLI.
| Option | Description |
|---|---|
-v, --version | Displays the current version of the CLI |
-h, --help | Displays help for command |
Commands
| Command | Description |
|---|---|
init [options] [path] | Initialize the Rehooks configuration |
add [options] [hooks] | Add custom hooks to your project |
list | List all available hooks in the API |
help [command] | Displays help for a specific command |
Init
Arguments
| Argument | Description |
|---|---|
path | Specify a custom path for hooks directory |
Options
| Option | Description |
|---|---|
-f, --force | Force overwrite existing configuration without prompt |
-c, --config <path> | Specify a custom path for rehooks.json |
-h, --help | Displays help for command |
Add
Arguments
| Argument | Description |
|---|---|
hooks | Specify hooks to add |
Options
| Option | Description |
|---|---|
-f, --force | Force overwrite existing hook files without prompt |
-h, --help | Displays help for command |