Skip to content

imLymei/foji

Repository files navigation

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

  • 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.

📦 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, and sync, 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:

  1. Required Arguments:
    These arguments must be provided for the command to run.

    "command": "echo <requiredArgumentOne> <requiredArgumentTwo>"
  2. Optional Arguments:
    These arguments are not mandatory. If not provided, they will be skipped.

    "command": "echo <requiredArgumentOne> <optionalArgumentOne?>"
  3. Optional Arguments with Default Values:
    If not provided, a default value will be used.

    "command": "echo <requiredArgumentOne> <optionalArgumentOne ?? My Default Value>"
  4. 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>"
  5. 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:

  1. Clone the repository:

    git clone https://github.com/imLymei/foji.git
    cd foji
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build:local

📜 Credits

This project makes use of several open-source libraries and tools. Special thanks to the following:

📄 License

Foji is licensed under the MIT License.

See the LICENSE file for more information.