Skip to content

pnstack/template-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Template Rust

A Rust project template featuring a todo application with SQLite database and terminal user interface (TUI).

Features

  • πŸ“ Todo management with SQLite persistence
  • πŸ–₯️ Interactive Terminal User Interface (TUI)
  • πŸ”§ Command Line Interface (CLI)
  • πŸ§ͺ Comprehensive test suite
  • πŸš€ CI/CD with GitHub Actions
  • πŸ“¦ Cross-platform releases
  • πŸ”’ Security auditing
  • 🐳 Docker and Docker Compose support
  • ❄️ Nix flakes for reproducible environments
  • πŸ“¦ Devcontainer configuration for GitHub Codespaces

Installation

πŸ’‘ Quick Start: See SETUP.md for detailed setup instructions using Docker, Nix, Codespaces, or local development.

From Source

git clone https://github.com/pnstack/template-rust.git
cd template-rust
cargo build --release

From Releases

Download the latest binary from the Releases page.

With Docker

# Build the image
docker build -t template-rust:latest .

# Run with interactive TUI
docker run --rm -it -v $(pwd)/data:/app/data template-rust:latest tui

# Or use Docker Compose
docker compose up

With Nix

# Enter development environment
nix develop

# Or run directly
nix run

With GitHub Codespaces

Click the "Code" button on GitHub and select "Create codespace on main" - everything is pre-configured!

Usage

Command Line Interface

# Show help
./template-rust --help

# Add a new todo
./template-rust add "Buy groceries" --description "Milk, eggs, bread"

# List all todos
./template-rust list

# List only completed todos
./template-rust list --completed

# List only pending todos
./template-rust list --pending

# Complete a todo (use the ID from list command)
./template-rust complete <todo-id>

# Delete a todo
./template-rust delete <todo-id>

# Start interactive TUI (default mode)
./template-rust tui

Terminal User Interface (TUI)

Start the interactive mode:

./template-rust tui

TUI Commands:

  • h - Show help
  • n - Add new todo
  • d - Delete selected todo
  • c - Toggle todo completion status
  • a - Show all todos
  • p - Show pending todos only
  • f - Show completed todos only
  • ↑↓ - Navigate todos
  • q - Quit application

Project Structure

template-rust/
β”œβ”€β”€ .github/workflows/    # CI/CD workflows
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ database/         # Database layer
β”‚   β”œβ”€β”€ models/           # Data models
β”‚   β”œβ”€β”€ tui/              # Terminal UI
β”‚   β”œβ”€β”€ lib.rs            # Library root
β”‚   └── main.rs           # CLI application
β”œβ”€β”€ tests/                # Integration tests
β”œβ”€β”€ docs/                 # Documentation
└── examples/             # Usage examples

Development

πŸ“š Full Setup Guide: See SETUP.md for comprehensive development environment setup instructions.

Prerequisites

Choose your preferred development method:

  • Local: Rust 1.70 or later, SQLite3
  • Docker: Docker 20.10+ and Docker Compose
  • Nix: Nix package manager with flakes enabled
  • Codespaces: Just a GitHub account!

Building

# Local
cargo build

# Docker
docker compose up --build

# Nix
nix build

Running Tests

cargo test

Running Clippy (Linter)

cargo clippy -- -D warnings

Formatting Code

cargo fmt

Development Environments

The project provides multiple development environment options:

  • Docker Compose: docker compose up dev - Containerized development with live code mounting
  • Nix Flakes: nix develop - Reproducible environment with all dependencies
  • Devcontainer: Open in VS Code or GitHub Codespaces - Fully configured IDE
  • Traditional: Local Rust installation with cargo

Database

The application uses SQLite for persistence. By default, it creates a todo.db file in the current directory. You can specify a different database path:

./template-rust --database /path/to/your/todos.db list

For testing with in-memory database:

./template-rust --database ":memory:" add "Test todo"

CI/CD

The project includes comprehensive GitHub Actions workflows:

  • CI (ci.yml): Build, test, lint, and format checks on multiple platforms (Linux, macOS, Windows)
  • Security (security.yml): Weekly security audits with cargo audit
  • Release (release.yml): Automated binary releases for Linux, macOS, and Windows on version tags
  • Docker (docker.yml): Docker image build testing and docker-compose validation

All workflows run automatically on push and pull requests to ensure code quality and security.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

This project is licensed under either of

at your option.

About

Rust starter template for dev

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors 2

  •  
  •