Command-line interface for MockFactory code execution sandbox
Project description
MockFactory CLI
Command-line interface for MockFactory - a secure multi-language code execution sandbox.
Execute code in isolated Docker containers with comprehensive security controls, directly from your terminal.
Features
- Multi-Language Support: Python, JavaScript, PHP, Perl, Go, Shell, HTML
- Secure Execution: All code runs in isolated containers with no network access
- Authentication: Login to access your account and execution history
- Usage Tracking: Monitor your execution limits and tier status
- Beautiful Output: Rich terminal formatting with syntax highlighting
- Easy to Use: Simple commands for quick code execution
Installation
pip install mockfactory-cli
Or install from source:
git clone https://github.com/afterdarksystems/mockfactory-cli.git
cd mockfactory-cli
pip install -e .
Quick Start
Execute code inline
mockfactory run python -c "print('Hello from MockFactory!')"
Execute a file
mockfactory execute script.py
Auto-detect language from file extension
mockfactory execute app.js
mockfactory execute script.php
mockfactory execute program.go
Commands
Authentication
Sign up for a free account
mockfactory signup
Creates a new account with 10 free executions per day.
Login to your account
mockfactory login
Check authentication status
mockfactory status
Logout
mockfactory logout
Code Execution
Run code inline
mockfactory run <language> -c "<code>"
# Examples:
mockfactory run python -c "print('Hello World')"
mockfactory run javascript -c "console.log('Hello World')"
mockfactory run php -c "echo 'Hello World';"
Run code from a file
mockfactory run <language> -f <file>
# Example:
mockfactory run python -f script.py
Execute a file (auto-detect language)
mockfactory execute <file>
# Examples:
mockfactory execute script.py # Python
mockfactory execute app.js # JavaScript
mockfactory execute program.go # Go
mockfactory execute script.sh # Shell
Set execution timeout
mockfactory run python -c "import time; time.sleep(2); print('done')" --timeout 60
Raw output mode
# Useful for piping or scripting
mockfactory run python -c "print('result')" --raw
Usage & Status
Check your usage
mockfactory usage
Shows:
- Current tier (anonymous, free, pro)
- Executions used
- Remaining executions
View configuration
mockfactory config show
Configuration
Set API URL
mockfactory config set api_url https://mockfactory.io
Set timeout
mockfactory config set timeout 60
Reset to defaults
mockfactory config reset
Supported Languages
| Language | Extension | Example |
|---|---|---|
| Python | .py |
mockfactory execute script.py |
| JavaScript | .js |
mockfactory execute app.js |
| PHP | .php |
mockfactory execute script.php |
| Perl | .pl |
mockfactory execute script.pl |
| Go | .go |
mockfactory execute program.go |
| Shell | .sh |
mockfactory execute script.sh |
| HTML | .html |
mockfactory execute page.html |
Usage Tiers
| Tier | Executions | Price | Features |
|---|---|---|---|
| Anonymous | 5/day | Free | No account required |
| Free Account | 10/day | Free | Execution history |
| Pro | Unlimited | $9.99/mo | Priority support |
Sign up for a free account:
mockfactory signup
Upgrade to Pro at mockfactory.io/pricing
Examples
Execute a Python script
mockfactory execute hello.py
Run inline JavaScript
mockfactory run javascript -c "const x = [1,2,3]; console.log(x.reduce((a,b) => a+b, 0))"
Execute with custom timeout
mockfactory execute long_running.py --timeout 120
Check how many runs you have left
mockfactory usage
Pipe output to another command
mockfactory run python -c "print('hello')" --raw | grep hello
Use in shell scripts
#!/bin/bash
result=$(mockfactory run python -c "print(2+2)" --raw)
echo "The answer is: $result"
Configuration Files
Configuration is stored in ~/.mockfactory/:
config.json- CLI configuration (API URL, timeout, etc.)token- Authentication token (automatically managed)
Security
- All code executes in isolated Docker containers
- No network access for sandbox containers
- Read-only filesystem (except
/tmp) - Resource limits enforced (CPU, memory, time)
- Runs as unprivileged user (
nobody)
Troubleshooting
Authentication errors
If you get authentication errors, try logging out and back in:
mockfactory logout
mockfactory login
Connection errors
Check your API URL configuration:
mockfactory config show
Reset to defaults if needed:
mockfactory config reset
Rate limiting
If you've exceeded your tier's execution limit:
- Wait for the daily reset
- Sign up for a free account (10 runs/day)
- Upgrade to Pro (unlimited)
Aliases
For convenience, you can use the short alias mf:
mf run python -c "print('shorter!')"
mf execute script.py
mf status
Development
Setup development environment
git clone https://github.com/afterdarksystems/mockfactory-cli.git
cd mockfactory-cli
pip install -e ".[dev]"
Run tests
pytest
Code formatting
black .
ruff check .
Links
- Website: mockfactory.io
- Documentation: github.com/afterdarksystems/mockfactory-cli
- Issues: github.com/afterdarksystems/mockfactory-cli/issues
License
MIT License - see LICENSE file for details
Support
For support, contact: support@afterdarksystems.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mockfactory_cli-0.1.0.tar.gz.
File metadata
- Download URL: mockfactory_cli-0.1.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a7ca55f227f2362fc97305bc50e720066239edbb119c870edde699edf169a56
|
|
| MD5 |
ea809c2eb938a8176f209c4a71dd1bc1
|
|
| BLAKE2b-256 |
db80cac4e145b2be2d8c63ca6a4d1f6226f377975286b3c6ffdc73ae58c5d7a8
|
File details
Details for the file mockfactory_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mockfactory_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
498a0d10b4f43608b82c2a00de2bdb8bfa2f8f6cd53b71467519d2b1c544d4c5
|
|
| MD5 |
098a8c4efd7879e4e21912de7835dedc
|
|
| BLAKE2b-256 |
f0ad1847236c5260f234f2c73d09860929a3ad4df72370fac26795f62a883dce
|