๐ cargo-setupx
Automate Rust project setup with modular configuration packs
A Rust-based CLI and library that automates the initial setup of new Rust projects. Provides modular configuration packs that can be selectively applied to standardize development environments.
๐ฏ Features
-
Quality Pack - Code quality configuration files
rustfmt.toml- Code formatting rulesclippy.toml- Linting configuration_typos.toml- Spell checking setupMakefile- Common development commands
-
Hooks Pack - Git hooks for automated quality checks
.githooks/pre-push- Pre-push quality gate.githooks/setup.sh- Hooks installation script- Configures
core.hooksPathautomatically
-
Architecture Pack - Project structure scaffolding
- Clean Architecture (domain, application, infrastructure, presentation)
- Additional patterns planned (hexagonal, onion - see Roadmap)
๐ฆ Installation
Or install from source:
๐ Quick Start
Apply All Packs
# In your Rust project directory
Apply Specific Packs
# Quality pack only
# Hooks pack only
# Architecture pack (clean)
# Quality + Hooks
Force Overwrite
# Overwrite existing files
# Skip confirmation prompt
๐ Usage
As a Cargo Subcommand
# Show help
# Apply to current directory
# Apply to specific directory
# Force overwrite with no prompts
As a Library
use ;
use Path;
let config = Config ;
apply_packs.expect;
๐ What Gets Created
Quality Pack (--quality)
Creates the following files in your project root:
clippy.toml # Clippy linter configuration
rustfmt.toml # Rustfmt formatter settings
_typos.toml # Typos spell checker config
Makefile # Development commands
Makefile commands:
make fmt- Format code (cargo fmt + taplo)make lint- Run clippy lintermake lint-fix- Auto-fix linting issuesmake check- Type check without buildingmake spell- Check spellingmake spell-fix- Auto-fix spelling errorsmake quality- Run all quality checksmake test- Run testsmake run- Run the application
Hooks Pack (--hooks)
Creates Git hooks for automated quality checks:
.githooks/
โโโ pre-push # Pre-push quality gate (executable)
โโโ setup.sh # Hook installation script (executable)
โโโ README.md # Hooks documentation
The pre-push hook runs:
- โ
Code formatting check (
cargo fmt --check) - โ
TOML formatting check (
taplo format --check) - โ
Linting (
cargo clippy -- -D warnings) - โ
Spell check (
typos) - โ
Type check (
cargo check) - โ
Tests (
cargo test)
Push is blocked if any check fails!
Architecture Pack (--arch=clean)
Note: Currently only Clean Architecture is supported. Other patterns (hexagonal, onion) are planned.
Creates Clean Architecture folder structure:
src/
โโโ domain/
โ โโโ entities/
โ โโโ repositories/
โ โโโ services/
โโโ application/
โ โโโ dto/
โ โโโ use_cases/
โโโ infrastructure/
โ โโโ database/
โ โโโ config/
โ โโโ http/
โโโ presentation/
โโโ handlers/
Each directory includes:
mod.rswith documentation- Stub files for quick start
๐ง Prerequisites
For full functionality, install these tools:
# Taplo (TOML formatter)
# Typos (spell checker)
๐ ๏ธ Development Workflow
After running cargo setupx --all, use these commands:
# Initial setup
# Daily development
# Testing
# Building
โ๏ธ Configuration
Idempotent Setup
Running cargo setupx multiple times is safe. It will:
- Skip existing files (unless
--forceis used) - Show clear status messages (Created, Skipped, Overwrote)
- Never corrupt existing files
Force Overwrite
Use --force to overwrite existing files:
Skip Confirmation
Use --yes to skip confirmation prompts:
๐จ Examples
New Project Setup
# Create new Rust project
# Apply all packs
# Setup git hooks
# Verify everything works
Existing Project Setup
# In your existing project
# Apply quality + hooks (no architecture changes)
# Setup hooks
Library Project
# Create library
# Apply quality pack + clean architecture
# Verify
๐งช Testing
Run the test suite:
Run specific tests:
๐ Documentation
Generate and open documentation:
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Make your changes
- Run quality checks (
make quality) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by the need for consistent Rust project setups
- Built with Clap for CLI parsing
- Quality tools: Clippy, Rustfmt, Typos
๐ Links
๐ง Roadmap
- Support for hexagonal architecture
- Support for onion architecture
- Custom pack definitions via
.setupx.toml - CI/CD configuration packs (GitHub Actions, GitLab CI)
- Docker configuration pack
- Plugin system for community packs
- Interactive mode for pack selection
Made with โค๏ธ by Ricardo Ferreira