A production-ready Rust project template with interactive CLI initialization.
- π¨ Interactive Setup - Beautiful CLI wizard guides you through project configuration
- π¦ Rust Best Practices - Pre-configured Cargo.toml with proper metadata
- π Auto-Generated Docs - README, LICENSE, and AUTHORS files created automatically
- π§ Flexible Project Types - Support for library, binary, or both
- π¦ Git Integration - Optional git initialization with first commit
- β Cargo Validation - Automatic cargo check after setup
- π― Clean Structure - Well-organized directory layout
git clone https://github.com/GafelSon/template-rs.git my-project
cd my-project
bash setup.sh
Or manually:
python3 init.py
The initializer will ask you for:
- Project name - Your project's name (e.g.,
my-awesome-tool
) - Crate name - Rust crate name (defaults to project name with underscores)
- Version - Semantic version (default:
0.1.0
) - Author - Your name and email (auto-detected from git config)
- Description - Brief description of your project
- License - Choose from MIT, Apache-2.0, GPL-3.0, BSD-3-Clause, MPL-2.0
- Repository - GitHub/GitLab repository URL
- Keywords - Comma-separated keywords for crates.io
- Categories - Select from predefined Rust categories
- Project type:
1
- Library only (lib.rs
)2
- Binary only (main.rs
)3
- Both library and binary
cd sources
cargo build
cargo test
cargo run # if binary type
template-rs/
βββ .gitignore # Git ignore rules
βββ README.md # Generated project documentation
βββ LICENSE # Generated license file
βββ AUTHORS # Generated authors file
βββ BEDEL # Notes and reflections space
βββ CHANGELOG # Project changelog (use logcast.py)
βββ TODO # Project task tracking
βββ init.py # Interactive project initializer
βββ setup.sh # Quick setup script
βββ logcast.py # Git log to changelog converter
βββ docs/
β βββ _site/ # Generated documentation site
β βββ wiki.md # Project wiki
βββ sources/ # Rust project directory
βββ Cargo.toml # Generated Rust manifest
βββ src/
β βββ lib.rs # Library entry point (if type: lib/both)
β βββ main.rs # Binary entry point (if type: bin/both)
βββ lib/ # Additional library modules
βββ man/ # Man pages
βββ unit-tests/ # Unit tests
In project root:
README.md
- Complete project documentation with badgesLICENSE
- Full license text based on your selectionAUTHORS
- Author and contributor information.git/
- Git repository (if you chose to initialize)
In sources/
directory:
Cargo.toml
- Complete Rust manifest with all metadatasrc/lib.rs
- Library template (if library type)src/main.rs
- Binary with "Hello Gafelson!" (if binary type)
python3 init.py
# Project name: my-cli-tool
# Type: 2 (binary)
# ... answer prompts ...
cd sources
cargo run
# Output: Hello Gafelson!
python3 init.py
# Project name: awesome-lib
# Type: 1 (library)
# ... answer prompts ...
cd sources
cargo build
cargo test
python3 init.py
# Project name: my-app
# Type: 3 (both)
# ... answer prompts ...
cd sources
cargo build --lib # Build library
cargo build --bin # Build binary
cargo run # Run binary
Converts git commit history into a formatted changelog:
./logcast.py
# Generates ChangeLog file from git history
- BEDEL - Document your thoughts, inspirations, and reflections
- TODO - Track project tasks and priorities
- CHANGELOG - Maintain version history
The initializer auto-detects git user info:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
- Python 3.6 or higher
- No external dependencies (uses only standard library)
- Rust 1.70.0 or higher (edition 2021)
- Cargo (comes with Rust)
- Creates
lib.rs
with module structure template - No
[[bin]]
section in Cargo.toml - Use for reusable libraries published to crates.io
- Creates
main.rs
with simple "Hello Gafelson!" example - Includes
[[bin]]
section in Cargo.toml - Use for executable applications/CLI tools
- Creates both
lib.rs
andmain.rs
- Library can be used as dependency
- Binary can use the library and provide CLI interface
Edit init.py
to customize generated files:
write_cargo()
- Modify Cargo.toml templatewrite_src()
- Customize source file templateswrite_readme()
- Change README structurewrite_license()
- Add more license options
Edit the cats
list in init.py
:
cats = [
"cli",
"web",
# Add your categories here
]
- Use Meaningful Names - Project names should be descriptive and follow Rust conventions
- Choose Right Type - Use
lib
for libraries,bin
for executables,both
for apps with library API - Add Keywords - Help others discover your crate on crates.io
- Pick Appropriate License - MIT/Apache-2.0 are common for open source Rust projects
- Update CHANGELOG - Use
logcast.py
or manually maintain version history - Track Tasks - Use the TODO file to organize development priorities
# Template is already initialized with git
git remote add origin https://github.com/yourusername/your-project.git
git push -u origin main
cd sources
cargo login
cargo publish
You selected library type but Cargo.toml has [[bin]]
section. Run init.py
again and choose the correct project type.
Ensure git is installed and configured:
git --version
git config --list
Make sure you're in the sources/
directory:
cd sources
cargo check
This template itself is released to the public domain. Generated projects use the license you select during initialization.
Soheil Fouladvandi <@gafelson>
Contributions welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
- Improve documentation
Made with β€οΈ for the Rust community