Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmadrosid/faker-cli
Generate fake data from your terminal.
https://github.com/ahmadrosid/faker-cli
Last synced: 22 days ago
JSON representation
Generate fake data from your terminal.
- Host: GitHub
- URL: https://github.com/ahmadrosid/faker-cli
- Owner: ahmadrosid
- Created: 2022-04-02T07:15:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-21T16:45:27.000Z (over 2 years ago)
- Last Synced: 2024-09-14T08:38:56.147Z (about 2 months ago)
- Language: Rust
- Homepage:
- Size: 170 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# faker-cli
Generate fake data from command line.
![demo](/demo.gif)```bash
faker-cli 0.1.0
Ahmad Rosid
Generate fake data.USAGE:
faker-cli [OPTION] [QUERY]OPTION:
-l --len Total length
-o --output Output default is JSON, [JSON,SQL]
-t --table Specify the table name for sql output.QUERY:
Example: "{ username, email }"
Output: { "username": "jhondoe", "email": "[email protected]" }Supported data.
- username
- password
- full_name
- first_name
- last_name
- zip_code
- phone_number
- text
```## Example
```bash
faker-cli -l 3 "{ username, email, password }"
```Result
```json
{"username": "mossie_et","email": "[email protected]","password": "eVJalW9no4O"}
{"username": "clotilde_qui","email": "[email protected]","password": "DxOhky"}
{"username": "nella_maiores","email": "[email protected]","password": "RY4L5Ck"}
```Custom attribute name.
```bash
faker-cli -l 3 "{ my_email(email), nickname(username), kode_pos(zip_code), rahasia(password), what_ever(1) }"
```Result
```json
{"my_email": "[email protected]","nickname": "blaze_autem","kode_pos": "134","rahasia": "Jr9TvZHQ4","what_ever": "1"}
{"my_email": "[email protected]","nickname": "tyler_ad","kode_pos": "4718","rahasia": "xCKsOVqYp","what_ever": "1"}
{"my_email": "[email protected]","nickname": "oswald_vel","kode_pos": "3206","rahasia": "BjM8uNGFS5","what_ever": "1"}
```## Example
You can use this with nodejs to seed your database.
```js
const child = require('child_process');
...
const cmd = `faker-cli -l 100 "{ username, email }"`;
child.exec(`${cmd}`, (err, stdout, stderr) => {
if (stdout.length > 0) {
stdout.split("\n").forEach(item => storeData(item))
}
});function storeData(data) {
db.user.create({
data: JSON.parse(data)
}).then(res => console.log(res))
.catch(err => {})
}
```Or you also can use to pipe with curl.
```bash
faker-cli -l 100 "{ username, email, password }" | xargs -I % sh -c 'curl -X POST http://localhost:8080/register -d "%s"'
```