Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
dacort committed Jun 13, 2024
1 parent 0926e74 commit c86c5e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ fake -n 10 pyint,user_name,date_this_year -f json -c id,awesome_name,last_attent
{"id": 1967, "awesome_name": "jmendoza", "last_attention_at": "2023-01-23"}
```

### Providers (beta)

While [Faker](https://faker.readthedocs.io) is a sweet library, we all like options don't we? [Mimesis](https://mimesis.name/en/master/) is _also_ awesome and can be quite a bit faster than Faker. 🤫 You can use a different provider by using `-p mimesis`.

> [!NOTE]
> Providers use their own syntax for data types, so you must change out your column names as necessary.
To generate the same dataset above with Mimesis for example:

```bash
fake -p mimesis -n 10 "numeric.integer_number(0),person.username,datetime.date(2024)" -f json -c id,awesome_name,last_attention_at
```

### Provider Arguments

Some [Faker providers](https://faker.readthedocs.io/en/master/providers/baseprovider.html) (like `pyint`) take arguments. You can also specify those if you like, separated by semi-colons (_because some arguments take a comma-separated string :)_)
Expand Down
2 changes: 1 addition & 1 deletion faker_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@click.option("--columns", "-c", help="Column names", default=None, required=False)
@click.option("--template", "-t", help="Template to use", type=click.Choice(["s3access", "cloudfront"]), default=None)
@click.argument("column_types", required=False)
@click.option("--provider", "-p", type=click.Choice(["faker", "mimesis"]), default="faker")
@click.option("--provider", "-p", help="Fake data provider", type=click.Choice(["faker", "mimesis"]), default="faker")
def main(num_rows, format, output, columns, template, column_types, provider):
"""
Generate fake data, easily.
Expand Down
2 changes: 1 addition & 1 deletion faker_cli/providers/mimesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def __init__(self) -> None:
self.field = Field()

def generate_row(self, column_types: list[tuple[str, list]]) -> list[str]:
return [self.field(ctype) for ctype, args in column_types]
return [self.field._lookup_method(ctype)(*args) for ctype, args in column_types]

def format(self, log_entry) -> list[str]:
raise NotImplementedError
Expand Down

0 comments on commit c86c5e9

Please sign in to comment.