Answer product-owner round 1: the hint for an empty stdin points to --list, the help's examples are templates only, the README's record id is an integer, and a test over an indexed module renders each path

This commit is contained in:
2026-10-11 23:29:23 +02:00
committed by Lillem4n
parent 00257e2851
commit 5e6330c75b
2 changed files with 4 additions and 4 deletions
+3 -2
View File
@@ -352,7 +352,7 @@ v = t.Fake() // render many times,
r, err := f.FakeRecord("users") // one record: each field a column
s := r.JSON() // {"first":"Ada","last":"Lovelace"}
r, err = f.FakeRecordTemplate(`{"format":"{x}","x":["a","b"]}`) // compile + render inline
rt, err := f.NewRecordTemplate(`{"format":"","id":"{seq(users)}"}`) // compile a record once
rt, err := f.NewRecordTemplate(`{"format":"","id":{"format":"{seq(users)}","datatype":"integer"}}`) // compile once
r = rt.Fake() // render a row; loop this for bulk output
err = f.FakeStruct(&user) // fill a struct's fake:"…" tagged fields
ok, err := fejkdata.IsTemplate(arg) // an inline template by its shape, else a path
@@ -459,7 +459,8 @@ 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 when it runs, so a test calling `fejkdata.New(fejkdata.WithDataFS(...))` over the
same modules catches broken data at `go test`. The CLI takes `fejkdata`'s flags
same modules, rendering each path once where a module carries an index, catches broken
data at `go test`. 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.
+1 -2
View File
@@ -29,7 +29,6 @@ COMMAND reads one template from stdin and renders it:
echo 'id: {int(1,999)}' | COMMAND
echo '{"format":"{x}","x":["bosse","lina"]}' | COMMAND
COMMAND --list # the paths a {/path} reference reads
COMMAND < template.txt
COMMAND <<'EOF'
@@ -630,7 +629,7 @@ func run(name string, modules []fs.FS, args []string, stdin io.Reader, stdout, s
func readStdin(stdin io.Reader, name string) (input, error) {
if stdin == nil {
return input{}, inputError{fmt.Errorf("the template comes from stdin, and nothing is piped in: %s", pipeHint(name))}
return input{}, inputError{fmt.Errorf("the template comes from stdin, and nothing is piped in: %s; %s --list prints the paths a {/path} reference reads", pipeHint(name), name)}
}
raw, err := io.ReadAll(stdin)
if err != nil {