Foji is a powerful command-line interface (CLI) tool designed to streamline and automate long or repetitive commands in your daily workflow. With Foji, you can define and execute custom commands, integrate custom parameters, and simplify complex processes, reducing the need to repeatedly type lengthy commands.
- Run custom commands with flexible argument handling.
- Supports options, conditional, and spread arguments for advanced customization.
- Easily add, edit and remove commands in the CLI.
- Sync configuration to the cloud.
Important
Foji requires Node.js to be installed on your system. Make sure you have it installed before proceeding.
To install Foji, run the following command:
npm i foji -g
Foji stores your commands and configurations in its configuration file (~/.config/foji.json
). You can access it using:
foji config
Or open it directly:
foji config -f
To execute a saved command
:
foji [command name] [...command args]
Tip
If you don’t provide a valid command name, Foji will list all available commands, including default commands like add
, remove
, and sync
, along with any custom commands you've added.
If you want to skip an optional argument, use the _
symbol:
foji [command name] [arg1] _ [arg3]
Foji allows you to easily create and update your command configurations.
To add a new command to the configuration:
foji add [command name] [command]
Supported argument types:
-
Required Arguments:
These arguments must be provided for the command to run."command": "echo <requiredArgumentOne> <requiredArgumentTwo>"
-
Optional Arguments:
These arguments are not mandatory. If not provided, they will be skipped."command": "echo <requiredArgumentOne> <optionalArgumentOne?>"
-
Optional Arguments with Default Values:
If not provided, a default value will be used."command": "echo <requiredArgumentOne> <optionalArgumentOne ?? My Default Value>"
-
Ternary Arguments:
Works as a boolean argument, only checking whether it was passed."command": "echo i want pizza of <requiredArgumentOne> with <hasCheese ? cheese : no cheese>"
-
Spread Argument:
Catches all the remaining arguments."command": "echo [<argOne>] {<argTwo...>}"
Example of usage:
foji command "my arg one" one two three --my --options
The resulting final command would be:
echo [my arg one] {one two three --my --options}
Important
Always provide required arguments before any optional ones.
To remove a command:
foji remove [command name]
You can easily sync your configurations using cloud services.
Note
Foji uses Github CLI to create, read and update your configuration gist.
To upload your configuration to a gist (or create a new gist if one doesn’t exist):
foji upload
To download a configuration file from a gist:
foji download [gist url]
To sync your local configuration with its URL:
foji sync
Caution
Be careful when syncing from external sources. Always verify the origin of the gist to avoid overriding your custom commands.
If you want to contribute or customize Foji, follow these steps:
-
Clone the repository:
git clone https://github.com/imLymei/foji.git cd foji
-
Install dependencies:
npm install
-
Build the project:
npm run build:local
This project makes use of several open-source libraries and tools. Special thanks to the following:
- TypeScript - Type-safe JavaScript.
- Commander - CLI framework.
- @inquirer/prompts - Command-line prompts.
- semantic-release - Automates versioning and package publishing.
- fast-levenshtein - Fast string distance algorithm.
Foji is licensed under the MIT License.
See the LICENSE file for more information.