Skip to content

Commit 97b2de4

Browse files
authored
Merge pull request #30 from imLymei/dev
Dev
2 parents 7f6c370 + fad50d9 commit 97b2de4

File tree

1 file changed

+118
-96
lines changed

1 file changed

+118
-96
lines changed

README.md

Lines changed: 118 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,198 @@
11
# Foji ⚒️
22

3-
Foji is a powerful command-line interface (CLI) tool crafted 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.
3+
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.
44

5-
## Features
5+
## 🚀 Features
66

7-
- [x] Run custom codes
8-
- [x] Handle custom parameters
9-
- [x] Conditional handler for arguments
10-
- [x] Support for default arguments
11-
- [x] Support for optional arguments
12-
- [x] Add commands to configuration file
13-
- [x] Remove commands from the configuration file
14-
- [x] Can run commands directly
15-
- [x] Configuration can be saved on cloud
16-
- [x] Configuration can be downloaded from cloud
17-
- [x] Local configuration can be synced from cloud
7+
- [x] Run custom commands with flexible argument handling.
8+
- [x] Supports options, conditional, and spread arguments for advanced customization.
9+
- [x] Easily add, edit and remove commands in the CLI.
10+
- [x] Sync configuration to the cloud.
1811

19-
## System Dependencies
12+
## 📦 Installation
2013

21-
Foji makes use of [Node.js](https://nodejs.org/) package manager to be installed.
14+
> [!IMPORTANT]
15+
> Foji requires [Node.js](https://nodejs.org/) to be installed on your system. Make sure you have it installed before proceeding.
2216
23-
## Installation
17+
To install Foji, run the following command:
2418

25-
To install Foji run the following command:
26-
27-
```shell
19+
```bash
2820
npm i foji -g
2921
```
3022

31-
## Usage
23+
## 🚦 Usage
24+
25+
Foji stores your commands and configurations in its configuration file (`~/.config/foji.json`). You can access it using:
26+
27+
```bash
28+
foji config
29+
```
30+
31+
Or open it directly:
3232

33-
Foji saves your commands and your configurations at it's configuration file (`~/.config/foji.json`). You can access the `.config` directory using `foji config` or open the file directly using `foji config -f` command.
33+
```bash
34+
foji config -f
35+
```
3436

3537
### Running a Command
3638

37-
To run a `command` just use:
39+
To execute a saved `command`:
3840

39-
```shell
41+
```bash
4042
foji [command name] [...command args]
4143
```
4244

43-
Simple as that.
45+
> [!TIP]
46+
> 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.
4447
45-
If you don't provide a valid command name Foji will list all available commands, it includes default commands (eg.: `add`, `remove` and `sync`) and your own commands.
48+
### Skipping an Argument
4649

47-
### Skipping a Argument
50+
If you want to skip an optional argument, use the `_` symbol:
4851

49-
You also can skip a (optional) argument using "\_":
50-
51-
```shell
52-
foji [command name] [argument one] _ [argument three]
52+
```bash
53+
foji [command name] [arg1] _ [arg3]
5354
```
5455

55-
## Creating and Updating the Configuration
56+
## ⚙️ Configuration Management
5657

57-
Foji provides easy ways to add `commands` to the configuration file (or create it if it does not exist):
58+
Foji allows you to easily create and update your command configurations.
5859

59-
### Creating a New Command
60+
### Adding a New Command
6061

61-
To add a new `command` to the configuration file you can use the `add` command:
62+
To add a new command to the configuration:
6263

63-
```shell
64+
```bash
6465
foji add [command name] [command]
6566
```
6667

67-
All `commands` can have four types of `arguments`:
68+
Supported argument types:
6869

69-
1. Required arguments:
70+
1. **Required Arguments**:
71+
These arguments **must** be provided for the command to run.
7072

71-
- These arguments **must** be provided for the command to run:
73+
```json
74+
"command": "echo <requiredArgumentOne> <requiredArgumentTwo>"
75+
```
7276

73-
```json
74-
"command":"echo <requiredArgumentOne> <requiredArgumentTwo>"
75-
```
77+
2. **Optional Arguments**:
78+
These arguments **are not mandatory**. If not provided, they will be skipped.
7679

77-
2. Optional arguments:
80+
```json
81+
"command": "echo <requiredArgumentOne> <optionalArgumentOne?>"
82+
```
7883

79-
- These arguments **are not** mandatory. If not provided, they will add nothing to the command.
84+
3. **Optional Arguments with Default Values**:
85+
If not provided, a default value will be used.
8086

81-
```json
82-
"command":"echo <requiredArgumentOne> <optionalArgumentOne?>"
83-
```
87+
```json
88+
"command": "echo <requiredArgumentOne> <optionalArgumentOne ?? My Default Value>"
89+
```
8490

85-
3. Optional arguments with default values:
91+
4. **Ternary Arguments**:
92+
Works as a boolean argument, only checking whether it was passed.
8693

87-
- Similar to optional arguments, but if not provided, they will add a default value. `<options ?? --ts --tailwind --src>`
94+
```json
95+
"command": "echo i want pizza of <requiredArgumentOne> with <hasCheese ? cheese : no cheese>"
96+
```
8897

89-
```json
90-
"command":"echo <requiredArgumentOne> <optionalArgumentOne ?? My Default Value>"
91-
```
98+
5. **Spread Argument**:
99+
Catches all the remaining arguments.
92100

93-
4. Ternaries:
101+
```json
102+
"command": "echo [<argOne>] {<argTwo...>}"
103+
```
94104

95-
- These arguments function like boolean arguments. Any value passed will be ignored by the CLI; it only checks **whether the argument was passed or not**.
105+
Example of usage:
96106

97-
```json
98-
"command":"echo i want pizza of <requiredArgumentOne> with <hasCheese?cheese:no cheese>"
107+
```bash
108+
foji command "my arg one" one two three --my --options
99109
```
100110

101-
Note that all `Required arguments` must be provided **BEFORE** any of the other arguments
111+
The resulting final command would be:
102112

103-
### Remove a Command
113+
```bash
114+
echo [my arg one] {one two three --my --options}
115+
```
104116

105-
To remove a `command` you can use the `remove` command
117+
> [!IMPORTANT]
118+
> **Always** provide required arguments **before** any optional ones.
106119
107-
```shell
108-
foji remove [command name] [command]
120+
### Removing a Command
121+
122+
To remove a command:
123+
124+
```bash
125+
foji remove [command name]
109126
```
110127

111-
### Configuration File Format
128+
## 🌐 Cloud Sync
112129

113-
Foji's configuration manage your `commands` and it's `url`:
130+
You can easily sync your configurations using cloud services.
114131

115-
```json
116-
{
117-
"gistUrl": "https://gist.github.com/.../...",
118-
"commands": {
119-
"next:create": "npx create-next-app@latest <dir ?? . >",
120-
"build": "npm run build:local",
121-
"next:dev": "npm run dev"
122-
}
123-
}
124-
```
132+
> [!NOTE]
133+
> Foji uses [Github CLI](https://cli.github.com/) to create, read and update your configuration gist.
125134
126-
### Upload Your Configuration File
135+
### Upload Configuration
127136

128-
To Upload your configuration to your gist (or create one if your configuration do not have yet) just run:
137+
To upload your configuration to a gist (or create a new gist if one doesn’t exist):
129138

130-
```shell
139+
```bash
131140
foji upload
132141
```
133142

134-
### Download Your Configuration File
143+
### Download Configuration
135144

136-
To download a configuration file from someone else just run this command:
145+
To download a configuration file from a gist:
137146

138-
```shell
147+
```bash
139148
foji download [gist url]
140149
```
141150

142-
### Sync Your Configuration File
151+
### Sync Configuration
143152

144-
Update you configuration file from it's url
153+
To sync your local configuration with its URL:
145154

146-
```shell
155+
```bash
147156
foji sync
148157
```
149158

150-
## Development
159+
> [!CAUTION]
160+
> Be careful when syncing from external sources. Always verify the origin of the gist to avoid overriding your custom commands.
151161
152-
If you want to contribute to Foji or customize it to your needs, you can clone the repository and build it yourself:
162+
## 🛠️ Development
163+
164+
If you want to contribute or customize Foji, follow these steps:
153165

154166
1. Clone the repository:
155167

156-
```shell
157-
git clone https://github.com/imLymei/foji.git
158-
cd foji
159-
```
168+
```bash
169+
git clone https://github.com/imLymei/foji.git
170+
cd foji
171+
```
160172

161-
2. Install the dependencies:
173+
2. Install dependencies:
162174

163-
```shell
164-
npm install
165-
```
175+
```bash
176+
npm install
177+
```
166178

167-
3. Build and install the project:
179+
3. Build the project:
168180

169-
```shell
170-
npm run build:local
171-
```
181+
```bash
182+
npm run build:local
183+
```
184+
185+
## 📜 Credits
186+
187+
This project makes use of several open-source libraries and tools. Special thanks to the following:
188+
189+
- [TypeScript](https://www.typescriptlang.org/) - Type-safe JavaScript.
190+
- [Commander](https://www.npmjs.com/package/commander) - CLI framework.
191+
- [@inquirer/prompts](https://www.npmjs.com/package/@inquirer/prompts) - Command-line prompts.
192+
- [semantic-release](https://www.npmjs.com/package/semantic-release) - Automates versioning and package publishing.
193+
- [fast-levenshtein](https://www.npmjs.com/package/fast-levenshtein) - Fast string distance algorithm.
172194

173-
## License
195+
## 📄 License
174196

175197
Foji is licensed under the MIT License.
176198

0 commit comments

Comments
 (0)