From 0dcc905f2fdc89f3be834c670a5bcf42386eb663 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 26 Dec 2023 11:21:59 -0600 Subject: Update docs --- README.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index e41f406..0e3b6ae 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,20 @@ Usually wiring up fake test data is a bunch of work, especially when that data i - Language agnostic - Dead simple and fast grammar to generate fixtures in minutes - Supports relations -- Writing in OCaml +- Written in OCaml ## Usage -Simply define a fixgen file, for example sample.fixgen - -``` -user (2): id uuidv4, name name, email email -purchase (10): id uuidv4, buyer user.id, amount int(1,40) -``` - -And then run it +Fixgen makes it simple to generate fixtures. It comes with a tiny DSL: ```sh -$ fixgen sample.fixgen -f csv -o fixtures +$ fixgen 'user (2): id uuidv4, name name; purchase (10): id uuidv4, buyer user.id, amount int<1,40>, currency: ("USD","MXN")' -o fixtures ``` -Or just generate in-line: +This will generate two files: -```sh -$ fixgen "user (2): id uuidv4, name name; purchase (10): id uuidv4, buyer user.id, amount int<1,40> -``` - -For it to generate two files with fake relational data: fixtures/purchase.csv, fixtures/user.csv. Bam! Simple as that. +- fixtures/user.csv, will have two rows containing id and name +- fixtures/purchase.csv, will have ten rows containing id, buyer (which will reference ids from user!), amount, currency. You can then import it into your SQL server with simple copy from commands @@ -40,6 +30,12 @@ COPY purchases FROM '/fixtures/purchase.csv' CSV HEADER; Or maybe export as JSON instead to import into your NoSQL DB. +```sh +$ fixgen 'user (2): id uuidv4, name name; purchase (3): id uuidv4, buyer user.id, amount int<1,40>, currency: ("USD","MXN")' -f json +``` + +This will print two JSON arrays to stdout. + ## Development - Prerequisites - [Nix](https://nixos.org/manual/nix/stable/installation/installing-binary) -- cgit v1.2.3