Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace subcommands with arguments #36

Merged
merged 16 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 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,57 @@ npm install --save-dev @faker-js/cli
## Usage

```
faker module_name method_name
npx faker <moduleName> <functionName>
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
```

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.

```bash
faker --help
```
## Examples

To list all possible methods of a module run:
If you want a integer you can run:

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

## Whats next

Upcoming features might include:

- localization
- support for all parameters `@faker-js/faker` natively
- make the CLI consumable for your own modules
### :hammer_and_wrench: Localization

You should be able to provide a specific locale for localized data.
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
Currently, the CLI will always use the default `en` locale.
This feature could look like this:

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

This example would print a first name of the German locale.

### :hammer_and_wrench: Support for All Parameters of `@faker-js/faker` Natively

This CLI is an MVP, currently.
This means that it does the bare minimum.
If you want an integer in a specific range, you are on your own.

In the future such a feature could look like this:

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

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

### :hammer_and_wrench: Better Documentation in the Terminal

Developers usually hate to switch work environments.
If you are already working in the terminal, you likely don't want to leave to check what to look up a little detail.
Instead you expect the CLI to have a proper `--help` documentation, including examples.
In the future, this should be the case.
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