Skip to content

faker-js/cli

Repository files navigation

Faker-CLI

A CLI of @faker-js/faker.

ℹ️ Note: This is currently a MVP.

Install

npm install --save-dev @faker-js/cli

Usage

npx faker [--module <moduleName>] <functionName>

ℹ️ Note: Read more about npx

Faker-CLI expects a functionName argument. An additional, optional --module (or short -m) might be provided in case of naming collisions for functionName.

This is equivalent to calling faker[moduleName][functionName] in any JavaScript environment. If no module option was given, the CLI will search through faker to find an appropriate function for your provided functionName.

Checkout Fakers's API for information on which modules and functions are available.

Examples

If you want a integer you can run:

npx faker int

of

npx faker -m number int

What's Next?

Upcoming features might include:

🛠️ 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:

npx faker --locale de -m person firstName

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

🛠️ 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:

npx faker -m 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.

🛠️ Better Documentation in the Terminal

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.

About

A CLI of @faker-js/faker.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •