Skip to content

Commit

Permalink
refactor: replace subcommands with arguments (#36)
Browse files Browse the repository at this point in the history
## Description

This PR significantly reduces the runtime duration of the CLI. This is
achieved by using a single CLI argument instead of subcommands. While
subcommands might be nicer for user experience, they are quite slow in
execution.
  • Loading branch information
xDivisionByZerox authored Dec 20, 2023
1 parent cdb57e1 commit 4bd2f5d
Show file tree
Hide file tree
Showing 282 changed files with 84 additions and 3,344 deletions.
52 changes: 40 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A CLI of [@faker-js/faker](https://github.com/faker-js/faker).

> **Note**: This is currently a [MVP](https://en.wikipedia.org/wiki/Minimum_viable_product).
> **:information_source: Note**: This is currently a [MVP](https://en.wikipedia.org/wiki/Minimum_viable_product).
## Install

Expand All @@ -13,27 +13,55 @@ npm install --save-dev @faker-js/cli
## Usage

```
faker module_name method_name
npx faker <moduleName> <functionName>
```

Faker-CLI expects a `module_name` as well as a `method_name` depending on the module chosen.
> **:information_source: Note**: [Read more about `npx`](https://docs.npmjs.com/cli/v7/commands/npx)
To list all possible modules run:
Faker-CLI expects a `moduleName` as well as a `functionName` argument.
This is equivalent to calling `faker[moduleName][functionName]`.
Checkout [Fakers's API](https://fakerjs.dev/api/) for information on which modules and functions are available.

## Examples

If you want a integer you can run:

```bash
faker --help
npx faker number int
```

To list all possible methods of a module run:
## What's Next?

Upcoming features might include:

### :hammer_and_wrench: Localization

Users will be able to specify a locale for localized data.
Currently, the CLI always uses the default `en` locale.
In the future, this feature could be implemented as follows:

```bash
faker module_name --help
npx faker --locale de person firstName
```

## Whats next
This example would print a first name from the German locale.

Upcoming features might include:
### :hammer_and_wrench: Support for All Parameters of `@faker-js/faker` Natively

This CLI is currently in its MVP stage, which means that it only performs the bare minimum.
If you need an integer within a specific range, you'll have to do it yourself.
In the future, this feature could be implemented as follows:

```bash
npx faker number int --min 10 --max 20
```

This example will generate an integer between 10 and 20.
The `min` and `max` options are available in [Faker's int options](https://fakerjs.dev/api/number.html#int).

### :hammer_and_wrench: Better Documentation in the Terminal

- localization
- support for all parameters `@faker-js/faker` natively
- make the CLI consumable for your own modules
Developers often dislike changing work environments.
If you're already working in the terminal, you probably don't want to leave it to look up a small detail.
Instead, you expect the CLI to have a proper `--help` documentation that includes examples.
This will be the case in the future.
10 changes: 0 additions & 10 deletions src/commands/airline/aircraftType.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/airline/airline.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/airline/airplane.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/airline/airport.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/airline/flightNumber.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/commands/airline/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/airline/recordLocator.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/airline/seat.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/bear.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/bird.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/cat.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/cetacean.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/cow.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/crocodilia.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/dog.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/fish.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/horse.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/commands/animal/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/insect.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/lion.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/rabbit.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/rodent.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/snake.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/animal/type.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/color/cmyk.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/color/colorByCSSColorSpace.ts

This file was deleted.

Loading

0 comments on commit 4bd2f5d

Please sign in to comment.