Skip to content

danielphan-dp/sdk-template

Repository files navigation

sdk-template

CI Dev Container Python 3.11+ Rust 2021 C++20 Lint: Ruff Types: Pyright Tests: pytest Rust Lints: clippy Build: CMake+Ninja pre-commit Commitizen License: Apache-2.0

Multilingual SDK/CLI template with Rust/C++ backends for performance-bound tasks. Production-ready starting point for building a CLI, with:

  • Dev Container + VS Code defaults for Python (ruff), Rust (rust-analyzer, clippy) and C++ (clang-format, cppcheck)
  • pre-commit hooks for formatting/linting
  • commitizen for Conventional Commits + changelog/version bumping

Prerequisites

Getting Started

1. Create your project

# Clone and rename
git clone https://github.com/YOUR_USERNAME/cli-template.git my-cli
cd my-cli
rm -rf .git && git init -b main

2. Customize for your CLI

Replace cli-template / cli_template with your project name:

File What to change
pyproject.toml name, description, [project.scripts]
src/cli_template/ Rename folder to your package name
.devcontainer/devcontainer.json "name" field
native/rust/Cargo.toml name, version
native/cpp/CMakeLists.txt project() name

3. Open in Dev Container

  1. Open folder in VS Code
  2. When prompted, click Reopen in Container (or run Dev Containers: Reopen in Container)
  3. Wait for container to build (~2-3 min first time)

4. Set up git hooks

pre-commit install
pre-commit install --hook-type commit-msg

Project Structure

src/cli_template/     # Python CLI (main entry point)
native/rust/          # Optional Rust backend
native/cpp/           # Optional C++ backend
tests/                # Test files
scripts/              # Build/release scripts
docs/                 # Documentation

Run the CLI

  • python -m cli_template hello --name alice
  • python -m cli_template echo hello world
  • python -m cli_template sum 2 3
  • python -m cli_template info

Optional native backends

Build the native backends and switch implementations with --impl.

Rust backend

  • Build: cargo build --manifest-path native/rust/Cargo.toml --release
  • Run: python -m cli_template --impl rust hello --name alice
  • Run: python -m cli_template --impl rust sum 2 3

C++ backend

  • Build:
    • cmake -S native/cpp -B build/native-cpp -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
    • cmake --build build/native-cpp
  • Run: python -m cli_template --impl cpp hello --name alice
  • Run: python -m cli_template --impl cpp echo hello world

Commit conventions

  • Create a commit: cz commit
  • Check your last commit message: cz check -r HEAD
  • Bump version + update changelog: cz bump

About

Multilingual SDK/CLI template with Rust/C++ backends for performance-bound tasks

Topics

Resources

License

Stars

Watchers

Forks