foji
v0.9.1
Published
Forge your code in a new way.
Downloads
82
Readme
Foji ⚒️
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.
🚀 Features
- [x] Run custom commands with flexible argument handling.
- [x] Supports options, conditional, and spread arguments for advanced customization.
- [x] Easily add, edit and remove commands in the CLI.
- [x] Sync configuration to the cloud.
📦 Installation
[!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
🚦 Usage
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
Running a Command
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
, andsync
, along with any custom commands you've added.
Skipping an Argument
If you want to skip an optional argument, use the _
symbol:
foji [command name] [arg1] _ [arg3]
⚙️ Configuration Management
Foji allows you to easily create and update your command configurations.
Adding a New Command
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.
Removing a Command
To remove a command:
foji remove [command name]
🌐 Cloud Sync
You can easily sync your configurations using cloud services.
[!NOTE] Foji uses Github CLI to create, read and update your configuration gist.
Upload Configuration
To upload your configuration to a gist (or create a new gist if one doesn’t exist):
foji upload
Download Configuration
To download a configuration file from a gist:
foji download [gist url]
Sync Configuration
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.
🛠️ Development
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
📜 Credits
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.
📄 License
Foji is licensed under the MIT License.
See the LICENSE file for more information.