Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
โ๏ธ Cargo-Forge
A powerful, interactive Rust project generator with intelligent templates and enterprise features
Generate production-ready Rust projects in seconds with intelligent templates, best practices, and optional features
๐ Quick Start
# Install cargo-forge
# Create a new project interactively
# Or specify project type directly
# Initialize in current directory
๐ Detailed Installation Guide - Including shell completions, pre-built binaries, and platform-specific instructions.
โจ Features
๐ฏ Project Types
Cargo-Forge supports 7 specialized project types, each with tailored templates and best practices:
| Type | Description | Key Features |
|---|---|---|
| cli-tool | Command-line applications | โข Clap argument parsingโข Colored outputโข Progress indicatorsโข Error handling |
| library | Rust library crates | โข Documentation templatesโข Example codeโข Benchmark setupโข CI/CD ready |
| api-server | REST API servers | โข Axum web frameworkโข JWT authenticationโข Database integrationโข OpenAPI docs |
| wasm-app | WebAssembly applications | โข wasm-bindgen setupโข Web-sys integrationโข Build scriptsโข HTML template |
| game-engine | Game development | โข Bevy engineโข Asset pipelineโข ECS architectureโข Dev tools |
| embedded | Embedded systems | โข no_std setupโข Memory configurationโข HAL integrationโข Debug configs |
| workspace | Multi-crate projects | โข Organized structureโข Shared dependenciesโข Cross-crate testingโข Unified CI |
๐ ๏ธ Optional Features
Enable powerful features during project creation:
CI/CD Integration
- GitHub Actions: Automated testing, releases, and deployment
- GitLab CI: Complete pipeline configuration with caching
- Custom CI: Template for other CI systems
Database Support
- PostgreSQL: SQLx integration with migrations
- MySQL: Full MySQL/MariaDB support
- SQLite: Embedded database with migrations
Authentication
- JWT: JSON Web Token authentication
- OAuth: OAuth2 with popular providers
- Password: Bcrypt-based password authentication
Additional Features
- Docker: Multi-stage Dockerfile and docker-compose
- Testing Frameworks: Property testing, benchmarks, integration tests
- Documentation: Auto-generated docs with examples
- Logging: Structured logging with tracing
๐ Comparison with cargo-generate
| Feature | cargo-forge | cargo-generate |
|---|---|---|
| Interactive Mode | โ Built-in with beautiful TUI | โ Requires manual input |
| Project Types | โ 7 specialized types | โ ๏ธ Generic templates |
| Smart Defaults | โ Intelligent suggestions | โ Manual configuration |
| Feature Combinations | โ Validated combinations | โ ๏ธ No validation |
| Dry Run Mode | โ Preview before creation | โ Not available |
| Config Files | โ Save/load preferences | โ ๏ธ Limited support |
| Non-interactive Mode | โ CI-friendly with defaults | โ Available |
| Custom Templates | โ Tera templates | โ Various engines |
| Conditional Logic | โ Smart conditionals | โ Basic support |
| Post-generation Hooks | โ Automatic setup | โ ๏ธ Manual scripts |
| Error Recovery | โ Graceful handling | โ ๏ธ Basic errors |
| Performance | โ ~1.5s generation | โ ๏ธ Varies by template |
๐ฎ Usage Examples
Interactive Mode (Recommended)
Command-Line Mode
# Create an API server with PostgreSQL and JWT auth
# Create a CLI tool in non-interactive mode (great for CI)
# Initialize a library in current directory
# Dry run to preview what will be created
# Use saved configuration
Advanced Usage
# Create a workspace with multiple crates
# Generate a game with Bevy engine
# Create an embedded project for STM32
๐ Generated Project Structure
Example: API Server
my-api/
โโโ src/
โ โโโ main.rs # Application entry point
โ โโโ routes/ # HTTP route handlers
โ โ โโโ mod.rs
โ โ โโโ health.rs
โ โ โโโ users.rs
โ โโโ models/ # Data models
โ โ โโโ mod.rs
โ โ โโโ user.rs
โ โโโ middleware/ # HTTP middleware
โ โ โโโ mod.rs
โ โ โโโ auth.rs
โ โโโ utils/ # Utility functions
โ โโโ mod.rs
โ โโโ config.rs
โโโ migrations/ # Database migrations
โ โโโ 001_initial.sql
โโโ tests/ # Integration tests
โ โโโ api_tests.rs
โโโ .github/ # GitHub Actions CI
โ โโโ workflows/
โ โโโ ci.yml
โโโ Dockerfile # Multi-stage Docker build
โโโ docker-compose.yml # Local development setup
โโโ .env.example # Environment variables template
โโโ Cargo.toml # Project manifest
โโโ README.md # Project documentation
๐ง Configuration
Global Configuration
Save your preferences for future projects:
# ~/.config/cargo-forge/config.toml
[]
= "Your Name"
= "MIT OR Apache-2.0"
= "git"
[]
= true
= "github"
= false
Project Configuration
Each project type supports specific configuration:
# forge.toml in your project
[]
= "api-server"
= ["database", "auth", "docker"]
[]
= "postgresql"
= "./migrations"
[]
= "jwt"
= "24h"
๐ Template Syntax
Cargo-Forge uses Tera templates with custom helpers:
// Conditional compilation based on features
use ;
// Smart defaults with fallbacks
const PORT: u16 = ;
// Case transformations
mod ;
{{ ;
// Feature combinations
// Authentication with database backend
๐งช Testing
Generated projects include comprehensive test setups:
# Run all tests
# Run with coverage
# Benchmarks (if enabled)
# Property tests (if enabled)
๐ข CI/CD Integration
All project types can include CI/CD configuration:
GitHub Actions
- Multi-platform testing (Windows, Mac, Linux)
- Rust version matrix (stable, beta, nightly)
- Security audits and dependency checks
- Release automation with cargo-release
- Code coverage with Codecov
GitLab CI
- Cached dependencies for faster builds
- Parallel job execution
- Deploy stages for different environments
- Container registry integration
๐ณ Docker Support
Generated Dockerfiles use multi-stage builds for optimal image size:
# Build stage
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/app /usr/local/bin/
CMD ["app"]
๐ Security
Cargo-Forge follows security best practices:
- No hardcoded secrets in templates
- Secure default configurations
- Environment variable usage for sensitive data
- Security audit integration in CI
- OWASP compliance for web projects
๐ค Contributing
We love contributions! See CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
# Run tests
# Run with coverage
# Build for release
๐ Performance
Cargo-Forge is optimized for speed:
- Project generation: ~1.5 seconds
- Template rendering: <100ms
- Feature validation: <50ms
- Cross-platform: Works on Windows, Mac, and Linux
๐ Troubleshooting
Common Issues
Q: Command not found after installation
# Ensure cargo bin directory is in PATH
Q: Permission denied errors
# Check directory permissions
# Use sudo if needed (not recommended)
Q: Template rendering fails
# Validate your input
# Check for special characters in project name
Getting Help
- ๐ Documentation
- ๐ฌ Discord Community (coming soon)
- ๐ Issue Tracker
- ๐ง Email Support (coming soon)
๐ Documentation
- Quick Reference - Command cheat sheet and quick examples
- Project Types Guide - Detailed guide for each project type
- Template Syntax - Tera template documentation
- FAQ - Frequently asked questions
- Troubleshooting - Common issues and solutions
- Contributing - Development guidelines
- Changelog - Version history and roadmap
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
๐ Acknowledgments
- The Rust community for invaluable feedback
- Contributors who help make Cargo-Forge better
- Projects that inspired us: cargo-generate, create-react-app, Rails generators
Built with โค๏ธ by the Rust community