Enhanced REPL
The FakeDataDSL REPL now includes visual inspection, step-through debugging, and table formatting.
Quick Start
fake_data_dsl repl
Commands
Basic Commands
load <path>- Load schemas from file/directorylist- List loaded schemasinfo <Schema>- Show schema detailsgen <Schema>- Generate one record (JSON format)gen <Schema> N- Generate N records (JSON format)seed <number>- Set seed for deterministic outputmode <mode>- Set mode (random/edge/invalid/hostile/mixed)help- Show helpquit/exit- Exit REPL
Enhanced Commands
table <Schema>- Generate one record (table view)table <Schema> N- Generate N records (table view)debug <Schema>- Step-through debugginginspect <Schema>- Detailed inspection (table + JSON + statistics)
Table View
Display records in a formatted table:
> table User
────────────────────┼───────────────────────────────
id │ "550e8400-e29b-41d4-a716-..."
name │ "John Doe"
email │ "john.doe@example.com"
age │ 34
For multiple records:
> table User 5
id │ name │ email
────────────────────┼─────────────────────┼─────────────────────
550e8400... │ John Doe │ john@example.com
f47ac10b... │ Jane Smith │ jane@example.com
...
Step-Through Debugging
Debug generation field-by-field:
> debug User
🐛 Debug Mode: Generating User
Press Enter to continue after each field, 'q' to quit, 'c' to continue without pausing
[Field 1] id
────────────────────────────────────────────────────────
Value: "550e8400-e29b-41d4-a716-446655440000"
Context State:
Depth: 0
Registry: available
Parent Context: no
Shared Context: none
Generated Fields:
(none yet)
Press Enter to continue, 'q' to quit, 'c' to continue without pausing:
[Field 2] name
────────────────────────────────────────────────────────
Value: "John Doe"
Context State:
Depth: 0
Registry: available
Parent Context: no
Shared Context: none
Generated Fields:
id = "550e8400-e29b-41d4-a716-446655440000"
Press Enter to continue, 'q' to quit, 'c' to continue without pausing: c
Continuing without pausing...
Debug Controls
- Enter - Continue to next field
- q / quit - Cancel debugging
- c / continue - Continue without pausing
Detailed Inspection
Get comprehensive information about generated records:
> inspect User
📊 Generated Record:
============================================================
────────────────────┼───────────────────────────────
id │ "550e8400-e29b-41d4-a716-..."
name │ "John Doe"
email │ "john.doe@example.com"
age │ 34
created_at │ "2024-01-15T10:30:00Z"
📋 JSON Format:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"email": "john.doe@example.com",
"age": 34,
"created_at": "2024-01-15T10:30:00Z"
}
📏 Statistics:
Fields: 5
Total size: 234 bytes
id: String (36)
name: String (8)
email: String (20)
age: Integer (2)
created_at: String (20)
Examples
Loading Schemas
> load schemas/
✅ Loaded 3 schema(s)
> list
Loaded schemas:
- User v1.0
- Order v2.3
- Product
Generating Data
> gen User
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Doe",
"email": "john.doe@example.com"
}
> gen User 5
[
{ "id": "...", "name": "John Doe", ... },
{ "id": "...", "name": "Jane Smith", ... },
...
]
Using Seeds
> seed 42
✅ Seed set to 42
> gen User
{
"id": "550e8400-e29b-41d4-a716-446655440000",
...
}
> gen User # Same seed = same output
{
"id": "550e8400-e29b-41d4-a716-446655440000",
...
}
Changing Modes
> mode edge
✅ Mode set to edge
> gen User
{
"id": "00000000-0000-0000-0000-000000000000",
"name": "",
"email": ""
}
> mode hostile
✅ Mode set to hostile
> gen User
{
"id": "' OR '1'='1",
"name": "<script>alert(1)</script>",
"email": "'; DROP TABLE users;--"
}
Use Cases
Debugging Complex Schemas
Use debug to understand how complex schemas with copy() and Ref() work:
> debug Order
# Step through each field to see context state
# Understand how copy() resolves parent fields
# See how Ref() resolves cross-schema references
Quick Data Inspection
Use table for quick visual inspection:
> table User 10
# See 10 users in a clean table format
# Easier to scan than JSON
Schema Exploration
Use inspect to understand schema output:
> inspect User
# See table + JSON + statistics
# Understand field types and sizes
# Verify schema structure
Tips
- Use seeds for reproducibility - Set a seed to get consistent output
- Use table view for quick checks - Faster than JSON for visual inspection
- Use debug for complex schemas - Understand field dependencies
- Use inspect for analysis - Get comprehensive information
Keyboard Shortcuts
- Ctrl+C - Interrupt current operation
- Ctrl+D - Exit REPL (same as
quit)
Configuration
The REPL respects global configuration:
FakeDataDSL.configure do |config|
config.default_mode = :edge
config.limits.max_array_size = 100
end
Troubleshooting
No Output
Check that schemas are loaded:
> list
No schemas loaded. Use 'load <path>' first.
Schema Not Found
Verify schema name:
> list
Loaded schemas:
- User
- Order
> gen User # Correct
> gen user # Wrong (case-sensitive)
❌ Schema 'user' not found
Debug Mode Not Working
Ensure on_field_generated callback is available (it's built-in, should work automatically).