| Crates.io | mockforge-cli |
| lib.rs | mockforge-cli |
| version | 0.3.45 |
| created_at | 2025-10-21 20:12:06.351872+00 |
| updated_at | 2026-01-18 16:39:01.443862+00 |
| description | CLI interface for MockForge |
| homepage | https://mockforge.dev |
| repository | https://github.com/SaaSy-Solutions/mockforge |
| max_upload_size | |
| id | 1894378 |
| size | 1,757,436 |
Command-line interface for MockForge - the comprehensive API mocking framework.
MockForge CLI provides a powerful command-line interface to manage MockForge servers, generate synthetic data, perform load testing, and orchestrate chaos experiments. It's the primary tool for interacting with MockForge in development, testing, and CI/CD environments.
git clone https://github.com/SaaSy-Solutions/mockforge.git
cd mockforge
cargo build --release --bin mockforge
# Binary will be available at target/release/mockforge
cargo install mockforge-cli
# Start all servers with default configuration
mockforge serve
# Start with custom ports and progress indicators
mockforge serve --http-port 8080 --ws-port 8081 --grpc-port 9090 --progress
# Start with OpenAPI spec and verbose logging
mockforge serve --spec api.yaml --verbose
# Start with admin UI, metrics, and progress bar
mockforge serve --admin --metrics --progress
# Generate mock server from OpenAPI spec
mockforge generate --spec api.yaml --output ./generated
# Generate with progress bar and verbose output
mockforge generate --spec api.json --output ./mocks --progress --verbose
# Watch mode for development (auto-regenerate on file changes)
mockforge generate --spec api.yaml --watch --progress
# Dry run to validate configuration
mockforge generate --config mockforge.toml --dry-run
# Generate user data
mockforge data template user --rows 100 --format json
# Generate from JSON schema
mockforge data schema my-schema.json --rows 50 --output data.json
# Load test an API
mockforge bench --spec api.yaml --target https://api.example.com --vus 50 --duration 30s
MockForge CLI provides comprehensive progress tracking and user feedback:
--verbose flagDevelopment-friendly watch mode automatically regenerates mock servers when files change:
# Watch OpenAPI spec for changes
mockforge generate --spec api.yaml --watch --progress
# Custom debounce time (default: 500ms)
mockforge generate --spec api.yaml --watch --watch-debounce 1000
Consistent exit codes for programmatic integration:
0: Success1: General error2: Invalid arguments3: File not found4: Permission denied5: Network error6: Configuration error7: Generation error8: Server errorserve)Start MockForge servers with comprehensive configuration options:
mockforge serve [OPTIONS]
--http-port, --ws-port, --grpc-port, --admin-port, --metrics-port--spec (OpenAPI), --ws-replay-file (WebSocket replay)--metrics, --tracing, --recorder--chaos, --traffic-shaping--ai-enabled, --rag-provider--progress, --verbose, --dry-run# Basic HTTP mock server
mockforge serve --http-port 3000
# Full-stack with all protocols and progress indicators
mockforge serve \
--http-port 3000 \
--ws-port 3001 \
--grpc-port 50051 \
--admin \
--metrics
# With chaos engineering
mockforge serve \
--chaos \
--chaos-scenario network_degradation \
--chaos-latency-ms 200
# With traffic shaping
mockforge serve \
--traffic-shaping \
--bandwidth-limit 1000000 \
--network-profile 3g
mqtt)# Start MQTT broker
mockforge mqtt serve --port 1883
# Publish message
mockforge mqtt publish --topic "sensors/temp" --payload '{"temp": 22.5}'
# Subscribe to topic
mockforge mqtt subscribe --topic "sensors/#"
# Manage topics
mockforge mqtt topics list
ftp)# Start FTP server
mockforge ftp serve --port 2121
# Manage virtual filesystem
mockforge ftp vfs add /test.txt --content "Hello World"
# Load fixtures
mockforge ftp fixtures load ./fixtures/ftp/
kafka) [requires kafka feature]# Start Kafka broker
mockforge kafka serve --port 9092
# Create topic
mockforge kafka topic create orders --partitions 3
# Produce message
mockforge kafka produce --topic orders --value '{"id": "123"}'
# Consume messages
mockforge kafka consume --topic orders --group test-group
amqp)# Start AMQP broker
mockforge amqp serve --port 5672
# Declare exchange
mockforge amqp exchange declare orders --type topic --durable
# Publish message
mockforge amqp publish --exchange orders --routing-key "order.created" --body '{"id": "123"}'
# Consume messages
mockforge amqp consume --queue orders.new
smtp) [requires smtp feature]# Send test email
mockforge smtp send --to user@example.com --subject "Test" --body "Hello World"
# Manage mailbox
mockforge smtp mailbox list
mockforge smtp mailbox show email-123
data)Generate synthetic test data using various methods:
mockforge data [SUBCOMMAND]
# Generate users
mockforge data template user --rows 100 --format json --output users.json
# Generate products with RAG enhancement
mockforge data template product --rows 50 --rag --rag-provider openai --output products.json
# Generate from custom schema
mockforge data schema my-schema.json --rows 200 --format csv --output data.csv
bench)Perform load testing using OpenAPI specifications:
mockforge bench --spec API.yaml --target https://api.example.com [OPTIONS]
--vus (virtual users), --duration, --scenario--target (API endpoint), --auth, --headers--operations, --method, --path--threshold-percentile, --threshold-ms, --max-error-rate# Basic load test
mockforge bench --spec api.yaml --target https://api.example.com --vus 10 --duration 1m
# Ramp-up scenario
mockforge bench --spec api.yaml --target https://staging.api.com --scenario ramp-up --vus 100
# Test specific endpoints
mockforge bench --spec api.yaml --target https://api.com --operations "GET /users,POST /users"
generate-tests)Generate test suites from recorded API interactions:
mockforge generate-tests --database recordings.db --format rust_reqwest [OPTIONS]
rust_reqwest - Rust with reqwestpython_pytest - Python with pytestjavascript_jest - JavaScript with Jestgo_test - Go with testinghttp_file - HTTP filescurl - cURL commandspostman - Postman collectionk6 - k6 load testing script# Generate Rust tests
mockforge generate-tests --format rust_reqwest --output tests.rs
# Generate with AI descriptions
mockforge generate-tests --format python_pytest --ai-descriptions --llm-provider openai
# Filter by endpoint
mockforge generate-tests --path "/api/users/*" --status-code 200
suggest, test-ai)suggest)Generate complete OpenAPI specs from minimal input:
# From text description
mockforge suggest --from-description "A blog API with posts and comments" --output api.yaml
# From example endpoint
mockforge suggest --from example.json --num-suggestions 10 --domain e-commerce
test-ai)Test AI-powered features:
# Test intelligent mock generation
mockforge test-ai intelligent-mock --prompt "Generate a REST API for a blog" --output mock.json
# Test event stream generation
mockforge test-ai event-stream --narrative "User login flow" --event-count 10
workspace)Multi-tenant workspace management:
# List workspaces
mockforge workspace list
# Create workspace
mockforge workspace create my-workspace --name "My Workspace"
# Workspace info
mockforge workspace info my-workspace
plugin)Manage MockForge plugins:
# List installed plugins
mockforge plugin list
# Install plugin
mockforge plugin install my-plugin
# Build plugin
mockforge plugin build ./my-plugin
orchestrate)Orchestrate chaos experiments:
# Start orchestration
mockforge orchestrate start --file orchestration.yaml --base-url http://localhost:3000
# Check status
mockforge orchestrate status --base-url http://localhost:3000
# Stop orchestration
mockforge orchestrate stop --base-url http://localhost:3000
sync)Bidirectional workspace synchronization:
# Start sync daemon
mockforge sync --workspace-dir ./workspaces
init)Initialize new MockForge projects:
# Initialize in current directory
mockforge init
# Initialize with custom name
mockforge init my-project
# Skip example files
mockforge init --no-examples
MockForge supports YAML configuration files:
# mockforge.yaml
http:
port: 3000
openapi_spec: "api.yaml"
websocket:
port: 3001
replay_file: "events.json"
grpc:
port: 50051
admin:
enabled: true
port: 9080
observability:
prometheus:
enabled: true
port: 9090
data:
rag:
enabled: true
provider: "openai"
model: "gpt-4"
Override configuration with environment variables:
export MOCKFORGE_HTTP_PORT=8080
export MOCKFORGE_RAG_API_KEY="sk-..."
export MOCKFORGE_LOG_LEVEL=debug
Generate shell completions:
# Bash
mockforge completions bash > mockforge.bash
# Zsh
mockforge completions zsh > _mockforge
# Fish
mockforge completions fish > mockforge.fish
Inject failures and test resilience:
# Network degradation
mockforge serve --chaos --chaos-scenario network_degradation
# Custom latency
mockforge serve --chaos --chaos-latency-ms 500 --chaos-latency-probability 0.8
# HTTP errors
mockforge serve --chaos --chaos-http-errors "500,502,503" --chaos-http-error-probability 0.1
# Rate limiting
mockforge serve --chaos --chaos-rate-limit 10
# Random chaos
mockforge serve --chaos-random --chaos-random-error-rate 0.05
Simulate network conditions:
# Bandwidth limiting
mockforge serve --traffic-shaping --bandwidth-limit 1000000
# Network profiles
mockforge serve --network-profile 3g
mockforge serve --network-profile satellite_leo
# List available profiles
mockforge serve --list-network-profiles
Leverage AI for enhanced mocking:
# Enable AI features
mockforge serve --ai-enabled --rag-provider openai --rag-model gpt-4
# Generate intelligent mocks
mockforge test-ai intelligent-mock --prompt "Create a user management API"
# AI-powered test generation
mockforge generate-tests --ai-descriptions --llm-provider ollama
Monitor and trace requests:
# Enable metrics
mockforge serve --metrics --metrics-port 9090
# Enable tracing
mockforge serve --tracing --tracing-service-name my-service --jaeger-endpoint http://localhost:14268/api/traces
# Enable API recorder
mockforge serve --recorder --recorder-db ./recordings.db
# 1. Initialize project
mockforge init my-api
# 2. Start development server
mockforge serve --admin --metrics
# 3. Generate test data
mockforge data template user --rows 100 --output users.json
# 4. Load test your API
mockforge bench --spec api.yaml --target http://localhost:3000 --vus 20 --duration 30s
# Validate configuration
mockforge serve --dry-run --config mockforge.yaml
# Generate tests from recordings
mockforge generate-tests --database recordings.db --format rust_reqwest --output integration_tests.rs
# Run chaos experiments
mockforge orchestrate start --file chaos.yaml --base-url $API_URL
# Start mock servers for testing
mockforge serve --spec api.yaml --chaos-random
# Generate test data
mockforge data schema test-schema.json --rows 1000 --output test-data.json
# Run load tests
mockforge bench --spec api.yaml --target $TEST_API_URL --scenario stress
Port already in use:
# Check what's using the port
lsof -i :3000
# Use different ports
mockforge serve --http-port 3001 --ws-port 3002
Configuration validation:
# Validate config before starting
mockforge config validate --config mockforge.yaml
Performance issues:
# Enable metrics to monitor performance
mockforge serve --metrics
# Check metrics at http://localhost:9090
See the main MockForge repository for contribution guidelines.
Licensed under MIT OR Apache-2.0