A template for cross-platform binary CLI projects written in Rust.
- Command-line argument parsing with clap
- Subcommand architecture ready to use (includes example
greetandechocommands) - Flexible verbosity control using
clap-verbosity-flag(supports-v,-vv,-vvv,-vvvv) - Structured logging with
logandenv_loggercrates - Error handling with
anyhowfor ergonomic error propagation
- Custom build script (
build.rs) that:- Detects and embeds glibc version for GNU targets
- Identifies C library linkage (glibc, musl, libSystem, libc)
- Detects static vs dynamic linking configuration
- Embeds Git commit hash at build time
- Embeds build timestamp in UTC
- Multi-platform support configured via
rust-toolchain.toml:- Linux: x86_64 and aarch64 (GNU and musl)
- macOS: x86_64 and aarch64 (Darwin)
- FreeBSD: x86_64
- Build matrix configuration (
matrix.jsonc) for cross-platform CI builds
- Rustfmt configuration (
rustfmt.toml) with:- Edition 2021 style
- 100 character line width
- Unix line endings
- Auto-reordering of imports and modules
- Clippy configuration (
clippy.toml) with custom linting rules - Code coverage setup with codecov integration (
codecov.yml) - Dependency management and security:
cargo-denyconfiguration (deny.toml) for:- License compliance checking (MIT, Apache-2.0, BSD-3-Clause, etc.)
- Security vulnerability scanning
- Dependency source validation
- Duplicate dependency detection
- Git hooks ready to use (in
hooks/directory):- Pre-commit hook: Runs formatting checks and linting on staged Rust files
- Pre-push hook: Runs full build and test suite before pushing
- Pre-push tag hook: Validates version consistency across Cargo.toml, Cargo.lock, and CHANGELOG.md
- Commit-msg hook: Enforces Conventional Commits format
- Auto-formatting of staged files via
fmt_staged.shhelper script
- Automated changelog generation with git-cliff
- Conventional commits parser configuration (
cliff.toml) with custom groups:- 🚀 Features
- 🐛 Bug Fixes
- 🚜 Refactor
- 📚 Documentation
- ⚡ Performance
- 🧪 Testing
- 🔧 Setup & Quality
- 🛡️ Security
◀️ Revert- ⚙️ Miscellaneous Tasks
Integrated task runner via just with comprehensive recipes:
- Building:
just build,just release - Testing:
just test,just test-integration - Code quality:
just fmt,just lint,just fix,just better - Pre-commit/push:
just pre-commit,just pre-push - Documentation:
just docs - Dependencies:
just deps,just update-deps,just outdated-deps - Security:
just audit,just licenses,just compliance - Coverage:
just coverage - Release: Run
just prepare-release VERSION, thenjust make-release VERSION - Cleaning:
just clean,just clean-all - CI:
just ci(runs full CI pipeline locally)
- Clean package manifest with comprehensive metadata (authors, repository, documentation, license)
- Minimum Rust version: 1.85.0 (specified in
Cargo.toml). You can change this based on your dependencies. - Stable toolchain with required components:
rustfmt,clippy,llvm-tools-preview - Proper exclusions for version control artifacts and IDE files
- Rust 1.85.0 or newer (toolchain will be installed automatically via
rust-toolchain.toml)- Components:
rustfmt,clippy,llvm-tools-preview(which are installed automatically)
- Components:
- git (required for version control and build script that embeds commit hash)
- just - Command runner for task automation (installation guide)
These cargo plugins enhance the development workflow but are not strictly required to build and run the project. Install them with just install-cargo-plugins:
- cargo-binstall - Fast cargo plugin installer
- cargo-edit - Manage Cargo.toml dependencies from CLI
- cargo-deny - Check licenses, security vulnerabilities, and dependencies
- cargo-semver-checks - Lint breaking changes in public API
- cargo-outdated - Check for outdated dependencies
- cargo-audit - Security vulnerability scanner
- cargo-llvm-cov - Code coverage tool
- git-cliff - Changelog generator for conventional commits
- glow - Markdown renderer for viewing changelog (used in
just changelogrecipe) - vim/nvim or any text editor (for
just prepare-releaserecipe). You can changenvimto the editor of your choice injustfilerecipe.
-
Click here use the template
-
Clone the newly created repo locally or in a Codespace
-
Setup the enviroment and make the first build:
# Install git hooks
just install-hooks
# Install required cargo plugins
just install-cargo-plugins
# Make the first build
just buildAll done!
Run the example commands:
cargo run -- greet "Rust Developer"
cargo run -- echo "Hello, World!"Run with verbose logging
cargo run -- -vvv greet WorldNow write some code and make it yours!
Use the following during development to make life easier:
just buildto build the projectjust betterto format and lint your codejust cito run the full CI pipeline locallyjust complianceto check for security issues and license compliance
You can always run just to see all available commands.
This project is licensed under the MIT License - see the LICENSE file for details.