Fail New without WithSeed, naming it, and seed the CLI from the system without --seed
This commit is contained in:
@@ -53,7 +53,7 @@ template holding one from a quoted heredoc or a file. The rest of stdin's rules
|
||||
|------|--|
|
||||
| `-d`, `--data-path D` | a directory to layer over the shipped data; repeatable, the last wins a name clash |
|
||||
| `--no-shipped-data` | load only the `--data-path` directories |
|
||||
| `-s`, `--seed N` | same seed, version and data: identical output |
|
||||
| `-s`, `--seed N` | same seed, version and data: identical output (default: a random seed) |
|
||||
| `-n`, `--repeat N` | render the template N times (0 to 1048576), each an independent draw, streamed; `0` prints nothing, `[]` under `--format json`, or the header under `--format csv` |
|
||||
| `--separator S` | between repeated renders (default empty); refused with a record `--format`, which has its own separators |
|
||||
| `--format F` | `text` (default), `json`, `ndjson`, `csv` or `sql` — a record's columns, one record per row (json frames them as an array) |
|
||||
@@ -360,7 +360,7 @@ ok, err := fejkdata.IsTemplate(arg) // an inline template by its shape, el
|
||||
|
||||
| Option | |
|
||||
|--------|--|
|
||||
| `WithSeed(n)` | same seed, version and data: identical sequence |
|
||||
| `WithSeed(n)` | required; same seed, version and data: identical sequence. `WithSeed(rand.Uint64())`, with `math/rand/v2`, draws afresh each run |
|
||||
| `WithDataPath(dir)` | layer a directory; repeat to layer several, the last wins a clash |
|
||||
| `WithDataFS(modules...)` | layer modules in order, each an `fs.FS`: a shipped package's `Modules()...`, or your own `embed.FS`; `WithDataFS()` loads none |
|
||||
|
||||
@@ -459,7 +459,7 @@ func main() { os.Exit(cli.Main(append(data.Modules(), mydata)...)) }
|
||||
The embed's folders are the paths: `//go:embed acme` serves `acme/customer.json` as
|
||||
`{/acme.customer}`. Add `*.tsv` to the embed where your data holds a table. The CLI loads
|
||||
its data only when it runs. To catch broken data at `go test`, call
|
||||
`fejkdata.New(fejkdata.WithDataFS(...))` over the same modules, and render each path once:
|
||||
`fejkdata.New(fejkdata.WithDataFS(...), fejkdata.WithSeed(1))` over the same modules, and render each path once:
|
||||
a module with an index checks a category only when a call first reaches it. The CLI takes `fejkdata`'s flags
|
||||
and exit codes, and names itself by the file it runs from in its help and errors. `--no-shipped-data` leaves out the modules passed to `Main`, and
|
||||
`--version` prints your module's version beside the fejkdata version it is built with.
|
||||
|
||||
Reference in New Issue
Block a user