Skip to main content

CLI (Node and Bun)

Use the CLI for local scripting, CI steps, and one-off batch generation.

When To Use This

  • You want command-line generation from text specs.
  • You want output to stdout or a file in scripts.

Node/npm CLI

Global install:

npm install -g @anywaydata/cli

Run without installing:

npx @anywaydata/cli --help

Common examples:

anywaydata --help
anywaydata generate -i input.txt -n 10 -f csv
anywaydata generate -i input.txt -n 10 -f json -o output.json
anywaydata generate -i input.txt -n 10 -f markdown -t
anywaydata amend --schema-file schema.txt --data-file input.csv --input-format csv -f json -o amended.json

Parameter guide for the examples:

  • generate: run the data generation command.
  • -i, --inputfile: path to the schema/input text file.
  • -n, --numberOfLines: number of rows to generate.
  • -f, --format: output format (for example csv, json, markdown, sql).
  • -o, --outputfile: optional output file path. If omitted, output is written to stdout.
  • -t, --testMode: generate one row and print diagnostics for troubleshooting.
  • --show-progress: explicitly control progress logs (for example --show-progress true or --show-progress false).
  • --stream: enable streaming generation when supported (csv, jsonl, dsv, json, xml).
  • --stream-threshold: auto-enable streaming when rowCount >= threshold and --outputfile is set (default 5000).
  • --unsafe-faker-expressions: opt-in to expression-style faker arguments (unsafe for untrusted input).
  • --help: show CLI usage and options.
  • amend --schema-file --data-file --input-format: import input data and amend it with schema rules.

Schema Formatting

Schema text supports:

  • Comments: lines starting with # (after optional leading whitespace) are treated as comments.
  • Blank lines: allowed and ignored, useful for readability between column groups.
  • Column definitions: each column name must be followed by its generation rule on the next logical content line.

Behavior Notes

  • --testMode always forces generation to a single row (rowCount = 1) and prints diagnostic/example output.
  • Progress output defaults to:
    • on for stdout mode (no --outputfile)
    • on for --testMode
    • off for file output unless --show-progress true is provided
  • Streaming is currently implemented for csv, jsonl, dsv, json, and xml exports. Other formats use buffered generation.
  • JSON stream mode emits a valid JSON array payload.
  • If a stream mode cannot honor some format options, generation continues and warnings are reported.
  • amend always uses buffered generation; stream flags are ignored for this command.
  • Auto-streaming (--stream-threshold) applies only when writing to a file. For stdout workflows, use --stream explicitly.
  • For amend, if -n/--numberOfLines is omitted, all imported rows are amended.
  • For amend, if -n/--numberOfLines is smaller than imported rows, only the first N rows are amended and full output is still returned.

Amend Examples

CSV input to tab-delimited output:

anywaydata amend \
--schema-file schema.txt \
--data-file input.csv \
--input-format csv \
-f dsv

Tab-delimited input to CSV output file:

anywaydata amend \
--schema-file schema.txt \
--data-file input.dsv \
--input-format dsv \
-f csv \
-o amended.csv

Amend only first two rows:

anywaydata amend \
--schema-file schema.txt \
--data-file input.csv \
--input-format csv \
-n 2 \
-f json

Example input.txt schema file:

# identity fields
Name
person.fullName

# contact details
Email
internet.email

# historical date
JoinedOn
date.past

This input format is the same schema format used in the Generating Data docs:

Bun CLI

From the repo root of grid-table-editor, you can run the Bun CLI entrypoint in apps/cli.

bun run apps/cli/src/bun-entry.js --help
bun run apps/cli/src/bun-entry.js generate -i input.txt -n 10 -f csv
bun run apps/cli/src/bun-entry.js generate -i input.txt -n 100000 -f jsonl -o output.jsonl --stream

If your environment uses a Bun-built binary/workflow, follow the same argument pattern.

Safe Faker Expressions

Node and Bun CLIs are safe-by-default for faker arguments.

To allow expression-style faker arguments, opt in explicitly:

anywaydata generate -i input.txt -n 10 -f csv --unsafe-faker-expressions

Choose CLI vs API/MCP

  • Choose CLI for local scripts and shell pipelines.
  • Choose REST API for HTTP integrations and OpenAPI.
  • Choose MCP for stdio tool integrations with MCP hosts.