Make everything replaceable goal 9, require changing inputs in the library and default them in the CLI, and record item 77's answers

This commit is contained in:
2026-10-04 22:07:37 +02:00
committed by Lillem4n
parent dc48ae11a5
commit 90be0ee6d8
5 changed files with 93 additions and 53 deletions
+31 -10
View File
@@ -177,9 +177,9 @@ carry sub-fields — `misc.currency.symbol`, `misc.territory.alpha2`,
Where a script under [`data-import/`](data-import) reads a source, the facts come from
that source, and the script drops a row only by a rule it states; elsewhere a small hand-written
set ships, and [`todo.md`](todo.md) carries the step that replaces it (goal 13). Copy
set ships, and [`todo.md`](todo.md) carries the step that replaces it (goal 14). Copy
that states no fact, such as `word` and `sentence`, stays hand-written. Where a category
has no path that draws only values reaching nothing real (goal 15), write a fixed value such
has no path that draws only values reaching nothing real (goal 16), write a fixed value such
as `example.com` into the template; `todo.md` plans the path.
`misc.httpmethod`, `misc.protocol` and `misc.port` are IANA's registries.
@@ -812,7 +812,7 @@ token {w} is repeated, and uppercase operand "w" holds "w" to one draw per expan
### Performance
The target is about a microsecond per value (goal 12).
The target is about a microsecond per value (goal 13).
With only the shipped set, `New` loads nothing: a category loads on the first `Fake`,
`FakeRecord`, `FakeStruct` or template that reads it, with every category it reads and
@@ -889,6 +889,8 @@ Where the project is heading; the sections before Audience document what ships t
1. It covers the ten most-spoken languages and the Nordic countries.
2. Each locale covers the common categories: names, addresses, phone numbers, ids,
companies and dates.
3. A library gets only the data and functions it hands to `New`, and fejkdata's own
load the same way as anyone else's.
3. **The code is easy to understand.**
1. You can go from a bug to the code behind it without asking anyone.
2. You can change one part without keeping the rest in your head.
@@ -916,23 +918,42 @@ Where the project is heading; the sections before Audience document what ships t
wrong.**
1. A template that could render a value its own rules forbid, such as `NaN` or `Inf`,
fails to load instead.
2. Data that reads something nobody provided fails to load, and the error names the
package that provides it by default.
7. **One command gets you a value.**
1. Flags work like in other command-line tools, and can go anywhere on the line.
2. Your first template of your own needs no escaping and no options.
3. The CLI fills in what you leave out with a sane default: all the shipped data, the
system's randomness and today's date.
8. **Data is JSON files and TSV tables. Code is only for what they can't express.**
9. **The same seed, version and data always give the same output.**
10. **It depends on nothing but Go's standard library.**
11. **The docs are a map of the template language.**
9. **Everything is replaceable.** Data, functions, and the packages they depend on can
come from fejkdata or anyone else.
1. A package names the packages it reads by default, and anything providing the same
paths can stand in for one.
2. Loading two things under one name fails, in the library and the CLI alike, unless
you say the second replaces the first.
3. The template language's own functions stay in the core, so a template means the
same in every program.
4. A function loaded from a package can ask for the input it needs, and gets the
randomness and the date the generator uses.
5. A CLI carrying your own packages is a few lines of Go, and works just like
`fejkdata`.
10. **The same seed, version and data always give the same output.**
1. A library call takes everything that can change its output from its caller: data,
randomness and the date.
11. **It depends on nothing but Go's standard library.**
12. **The docs are a map of the template language.**
1. Every feature has its own heading.
2. Every example runs as a test and shows its output.
3. Each rule is stated in one place.
12. **It is fast enough that you never notice it.**
13. **Every fact comes from an official or open source,** such as a government
13. **It is fast enough that you never notice with the shipped data, and its cost grows
with the data a render reaches, not with all the data loaded.**
14. **Every fact comes from an official or open source,** such as a government
register.
1. A table holds every row its source holds, and nothing added by hand.
14. **The most common data comes first,** such as names, addresses, phone numbers and
15. **The most common data comes first,** such as names, addresses, phone numbers and
dates.
15. **Values look real by default. You can also ask for values that can never reach
16. **Values look real by default. You can also ask for values that can never reach
anything real,** such as a domain nobody can register.
## Layout