| Crates.io | cargo-forge |
| lib.rs | cargo-forge |
| version | 0.1.5 |
| created_at | 2025-07-03 04:53:13.392992+00 |
| updated_at | 2025-11-27 02:54:55.897876+00 |
| description | An interactive Rust project generator with templates and common features |
| homepage | https://cargo-forge.rs |
| repository | https://github.com/marcuspat/cargo-forge |
| max_upload_size | |
| id | 1735809 |
| size | 493,449 |
An interactive Rust project generator with templates and common features
Generate Rust projects with templates and optional features
# Install cargo-forge
cargo install cargo-forge
# Create a new project interactively
cargo-forge new
# Or specify project type directly
cargo-forge new my-api --project-type api-server
# Initialize in current directory
cargo-forge init --project-type library
๐ Detailed Installation Guide - Including shell completions, pre-built binaries, and platform-specific instructions.
Cargo-Forge supports 7 project types with templates:
| Type | Description | Key Features |
|---|---|---|
| cli-tool | Command-line applications | โข Clap dependency setup โข Basic project structure โข Ready for CLI development |
| library | Rust library crates | โข Library template โข Examples directory โข Documentation ready โข Tests structure |
| api-server | REST API servers | โข Axum web framework โข Basic HTTP server setup โข Route handlers structure โข Ready for API development |
| wasm-app | WebAssembly applications | โข wasm-bindgen setup โข Web-sys integration โข Build scripts โข HTML template |
| game-engine | Game development | โข Bevy engine โข Asset pipeline structure โข Basic game setup โข Development ready |
| embedded | Embedded systems | โข no_std setup โข Memory configuration โข HAL integration โข Debug configs |
| workspace | Multi-crate projects | โข Organized structure โข Shared dependencies โข Cross-crate testing โข Unified configuration |
Current features available in v0.1.3:
| Feature | cargo-forge | cargo-generate |
|---|---|---|
| Interactive Mode | โ Planned for future | โ Requires manual input |
| Project Types | โ 7 specialized types | โ ๏ธ Generic templates |
| Defaults | โ Pre-configured options | โ Manual configuration |
| Name Validation | โ Built-in validation | โ ๏ธ Basic validation |
| Dry Run Mode | โ Preview before creation | โ Not available |
| Non-interactive Mode | โ CI-friendly with defaults | โ Available |
| Custom Templates | โ Tera templates | โ Various engines |
| Shell Completions | โ All major shells | โ ๏ธ Manual setup |
| Error Recovery | โ Graceful handling | โ ๏ธ Basic errors |
| Performance | โ <0.1s generation | โ ๏ธ Varies by template |
# Create an API server with PostgreSQL and JWT auth
cargo-forge new my-api \
--project-type api-server \
--author "Jane Doe" \
--description "My awesome API"
# Create a CLI tool in non-interactive mode (great for CI)
cargo-forge new my-cli \
--project-type cli-tool \
--non-interactive
# Initialize a library in current directory
cargo-forge init --project-type library
# Dry run to preview what will be created
cargo-forge new my-project --dry-run
# Use saved configuration
cargo-forge new my-project --from-config ~/.forge/defaults.toml
# Create a workspace with multiple crates
cargo-forge new my-workspace --project-type workspace
# Generate a game with Bevy engine
cargo-forge new my-game --project-type game-engine
# Create an embedded project for STM32
cargo-forge new my-firmware --project-type embedded
my-api/
โโโ src/
โ โโโ main.rs # Application entry point
โ โโโ handlers.rs # HTTP handlers (basic structure)
โ โโโ routes.rs # Route definitions (basic structure)
โ โโโ models.rs # Data models (basic structure)
โโโ config/
โ โโโ default.toml # Configuration template
โโโ tests/ # Test directory
โโโ .gitignore # Git ignore file
โโโ Cargo.toml # Project manifest with Axum dependencies
โโโ README.md # Project documentation
Cargo-Forge supports various command-line options:
# Non-interactive mode (great for CI/CD)
cargo-forge new my-project --project-type api-server --non-interactive
# Dry run to preview what will be created
cargo-forge new my-project --project-type library --dry-run
# Initialize in current directory
cargo-forge init --project-type cli-tool
After project creation, you can customize:
Cargo.tomlCargo-Forge uses Tera templates with custom helpers:
// Conditional compilation based on features
{% if database %}
use sqlx::{PgPool, postgres::PgPoolOptions};
{% endif %}
// Smart defaults with fallbacks
const PORT: u16 = {{ port | default(value=3000) }};
// Case transformations
mod {{ name | snake_case }};
struct {{ name | pascal_case }};
// Feature combinations
{% if auth and database %}
// Authentication with database backend
{% endif %}
Generated projects include comprehensive test setups:
# Run all tests
cargo test
# Run with coverage
cargo tarpaulin
# Benchmarks (if enabled)
cargo bench
# Property tests (if enabled)
cargo test --features proptest
All project types can include CI/CD configuration:
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"]
Cargo-Forge security features:
We love contributions! See CONTRIBUTING.md for guidelines.
# Clone the repository
git clone https://github.com/yourusername/cargo-forge
cd cargo-forge
# Run tests
cargo test
# Run with coverage
cargo tarpaulin
# Build for release
cargo build --release
Cargo-Forge is optimized for speed:
Q: Command not found after installation
# Ensure cargo bin directory is in PATH
export PATH="$HOME/.cargo/bin:$PATH"
Q: Permission denied errors
# Check directory permissions
ls -la .
# Use sudo if needed (not recommended)
Q: Template rendering fails
# Validate your input
cargo-forge new --dry-run
# Check for special characters in project name
Licensed under either of:
at your option.
Built with โค๏ธ by the Rust community