| Crates.io | jgd-rs-cli |
| lib.rs | jgd-rs-cli |
| version | 0.2.1 |
| created_at | 2025-08-13 11:17:42.963366+00 |
| updated_at | 2025-08-18 17:58:48.219943+00 |
| description | Command-line tool for generating JSON data from JGD (JSON Generator Definition) schema files |
| homepage | https://github.com/lvendrame/jgd-rs/jgd-rs-cli/ |
| repository | https://github.com/lvendrame/jgd-rs |
| max_upload_size | |
| id | 1793555 |
| size | 37,936 |
A command-line interface for generating JSON data from JGD (JSON Generator Definition) schema files.
The JGD-rs CLI tool allows you to generate realistic JSON data from declarative schema definitions directly from the command line. It's built on top of the jgd-rs library and provides a simple interface for batch JSON generation, testing, and data seeding.
Clone the repository and build the CLI tool:
git clone https://github.com/lvendrame/jgd-rs.git
cd jgd-rs
cargo build --release
The binary will be available at ./target/release/jgd-rs-cli.
cargo install --path jgd-rs-cli
jgd-rs-cli [OPTIONS] <INPUT>
<INPUT> - Path to the .jgd schema file-o, --out <FILE> - Output file (JSON). If omitted, prints to stdout--seed <SEED> - Seed override for deterministic generation-p, --pretty - Pretty print the JSON output-h, --help - Print help information-V, --version - Print version informationGenerate JSON data and print to stdout:
jgd-rs-cli schema.jgd
Generate JSON data and save to a file:
jgd-rs-cli schema.jgd -o output.json
Generate formatted JSON with proper indentation:
jgd-rs-cli schema.jgd --pretty
Generate deterministic data with a specific seed:
jgd-rs-cli schema.jgd --seed 42 --pretty
jgd-rs-cli examples/user-post-entities.jgd --seed 12345 --pretty --out generated-data.json
This command:
user-post-entities.jgd schema filegenerated-data.jsonThe repository includes several example schema files you can use:
# Generate a single user object
jgd-rs-cli ../examples/single-object-root.jgd --pretty
# Generate an array of objects
jgd-rs-cli ../examples/array-object-root.jgd --pretty
# Generate complex multi-entity data
jgd-rs-cli ../examples/user-post-entities.jgd --pretty
user.jgd){
"$format": "jgd/v1",
"version": "1.0.0",
"root": {
"fields": {
"id": "${ulid}",
"name": "${name.name}",
"email": "${internet.safeEmail}",
"age": {
"number": {
"min": 18,
"max": 65,
"integer": true
}
},
"city": "${address.cityName}",
"active": true
}
}
}
jgd-rs-cli user.jgd --pretty
{
"id": "01HQCR5K2X3QP2M9T4N6B7V8Z0",
"name": "Alice Johnson",
"email": "alice.johnson@example.org",
"age": 29,
"city": "Springfield",
"active": true
}
Generate test data for API endpoints:
# Generate user test data
jgd-rs-cli schemas/user.jgd -o test-data/users.json
# Generate product catalog
jgd-rs-cli schemas/products.jgd --seed 100 -o test-data/products.json
Create seed data for development databases:
# Generate 1000 users with relationships
jgd-rs-cli schemas/large-dataset.jgd --seed 42 -o seed-data.json
Create realistic mock data for frontend development:
# Generate blog posts with authors
jgd-rs-cli schemas/blog-system.jgd --pretty -o frontend/mock-data.json
Generate consistent test data for data processing pipelines:
# Generate reproducible test data
jgd-rs-cli schemas/pipeline-input.jgd --seed 123 -o pipeline-test-input.json
.PHONY: generate-test-data
generate-test-data:
jgd-rs-cli schemas/users.jgd --seed 42 -o test-data/users.json
jgd-rs-cli schemas/products.jgd --seed 42 -o test-data/products.json
jgd-rs-cli schemas/orders.jgd --seed 42 -o test-data/orders.json
.PHONY: clean-test-data
clean-test-data:
rm -rf test-data/*.json
{
"scripts": {
"generate:mockdata": "jgd-rs-cli schemas/frontend-data.jgd --pretty -o src/mock-data.json",
"generate:testdata": "jgd-rs-cli schemas/test-data.jgd --seed 42 -o tests/fixtures/data.json"
}
}
FROM rust:1.70 as builder
COPY . /app
WORKDIR /app
RUN cargo build --release
FROM debian:bullseye-slim
COPY --from=builder /app/target/release/jgd-rs-cli /usr/local/bin/
COPY schemas/ /schemas/
CMD ["jgd-rs-cli", "/schemas/default.jgd", "--pretty"]
Error: Schema validation failed
Solution: Ensure your schema follows the JGD format. See the schema documentation.
Error: No such file or directory
Solution: Check that the input file path is correct and the file exists.
Error: Permission denied (os error 13)
Solution: Ensure you have read permissions for the input file and write permissions for the output directory.
For troubleshooting, you can use Rust's built-in logging:
RUST_LOG=debug jgd-rs-cli schema.jgd --pretty
The CLI tool automatically validates input schemas against the JGD specification. For additional validation, you can use external JSON Schema validators with the JGD schema definition.
0 - Success1 - Error (invalid schema, file not found, etc.)Contributions are welcome! To contribute to the CLI tool:
This project is licensed under the MIT License - see the LICENSE file for details.