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 3 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
52 changes: 41 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,57 @@ npm install --save-dev @faker-js/cli
## Usage

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

Faker-CLI expects a `module_name` as well as a `method_name` depending on the module chosen.
> [ℹ: Read more about `npx`](https://docs.npmjs.com/cli/v7/commands/npx)

To list all possible modules run:
Faker-CLI expects a `functionName`.
This is equivalent to the names in Faker's modules.
Checkout [their API](https://fakerjs.dev/api/) for information on which 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 int
```

## Whats next

Upcoming features might include:

- localization
- support for all parameters `@faker-js/faker` natively
- make the CLI consumable for your own modules
### 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 firstName
```

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

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

This CLI is an MVP, currently.
This means that it does the bear minimum.
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
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 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).

# 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