Skip to content
/ c23-cli-template Public template

Modern C23 CLI application starter with Zig build system, NCurses TUI support, and comprehensive project structure

License

Notifications You must be signed in to change notification settings

sammyjoyce/c23-cli-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

CLI Starter Template - C23 + Zig πŸš€

GitHub Release License CI Status Codecov Zig Build CodeQL OpenSSF Scorecard

A modern C23 CLI application starter template with Zig build system

Use this template β€’ View Demo β€’ Report Bug


✨ Features

  • πŸš€ Modern C23 - Latest C standard with Aro compiler
  • ⚑ Zig Build System - Fast, reliable builds with cross-compilation
  • πŸ—οΈ Well-Structured - Organized project layout ready for growth
  • πŸ§ͺ Testing Included - Test framework with examples
  • 🎨 Smart CLI - Colored output, help text, argument parsing
  • πŸ–ΌοΈ TUI Support - NCurses integration for interactive terminal UIs
  • πŸ”§ Configuration - Layered config system (file β†’ env β†’ args)
  • πŸ“¦ Minimal Dependencies - Only Zig, libc, and ncurses
  • πŸ€– CI/CD Ready - GitHub Actions workflow included
  • πŸ”„ Conditional Runners - Uses self-hosted runners for template repo, GitHub-hosted for derived repos
  • ⚑ Caching - Speeds up builds by caching Zig dependencies and build artifacts
  • πŸ”’ Release Gating - Ensures releases only happen on tags in main branch
  • πŸ›‘οΈ Security Scanning - CodeQL integration for vulnerability detection
  • πŸ“¦ Artifact Management - Unique artifact naming to avoid collisions
  • 🏷️ Version Pinning - Pinned GitHub Actions versions for reproducibility
  • 🚫 Concurrency Control - Cancels redundant CI runs on same branch
  • πŸ“Š Dynamic Binary Naming - Extracts binary name from build.zig.zon
  • 🧹 Template Cleanup - Automated cleanup of template-specific files and placeholders
  • πŸ“š OpenCLI Compliant - Standardized CLI behavior
  • πŸ”„ Dependency Updates - Automated updates with Dependabot/Renovate
  • πŸ“ Pre-commit Hooks - Code quality enforcement before commits
  • 🐳 Devcontainer Support - Consistent development environments
  • πŸ“‹ Comprehensive Documentation - Detailed guides and examples

🎯 Quick Start

Create Your Project

Option 1: GitHub UI

  1. Click "Use this template"
  2. Name your repository
  3. Click "Create repository"

Option 2: GitHub CLI

gh repo create my-cli \
  --template sammyjoyce/c23-cli-template \
  --public \
  --clone

Build & Run

# Clone your new repo
git clone https://github.com/YOU/YOUR-REPO
cd YOUR-REPO

# Build (with TUI support)
zig build -Doptimize=ReleaseSafe

# Build without TUI (if ncurses is not available)
zig build -Doptimize=ReleaseSafe -Denable-tui=false

# Run
./zig-out/bin/YOUR-REPO --help

πŸ“– What's Included

Project Structure

your-cli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.c              # Entry point
β”‚   β”œβ”€β”€ core/               # Core functionality
β”‚   β”‚   β”œβ”€β”€ config.c/h      # Configuration
β”‚   β”‚   β”œβ”€β”€ error.c/h       # Error handling
β”‚   β”‚   └── types.h         # Type definitions
β”‚   β”œβ”€β”€ cli/                # CLI interface
β”‚   β”‚   β”œβ”€β”€ args.c/h        # Argument parsing
β”‚   β”‚   └── help.c/h        # Help text
β”‚   β”œβ”€β”€ io/                 # Input/Output
β”‚   └── utils/              # Utilities
β”œβ”€β”€ test/                   # Test suite
β”œβ”€β”€ build.zig               # Build config
└── opencli.json            # CLI specification

Example Commands

The template includes working examples:

# Greeting command
$ myapp hello
Hello, World!

$ myapp hello Alice
Hello, Alice!

# Echo command
$ myapp echo Hello from CLI
Hello from CLI

# Info command
$ myapp info
Application: myapp
Version: 1.0.0
Build: Jul 27 2025 13:16:11

# Interactive TUI menu
$ myapp menu
# Opens an ncurses-based interactive menu

πŸ› οΈ Customization Guide

1. After Creating Your Repo

The template automatically:

  • βœ… Replaces myapp with your project name
  • βœ… Updates all references and metadata
  • βœ… Preserves template structure
  • βœ… Removes template-specific files
  • βœ… Commits the changes

Check the Actions tab to see progress.

2. Add Your Commands

Edit src/main.c:

if (strcmp(command, "deploy") == 0) {
    printf("Deploying application...\n");
    // Your deployment logic
    return APP_SUCCESS;
}

3. Update Help Text

Edit src/cli/help.c to describe your commands.

4. Add Source Files

  1. Create your .c file in src/
  2. Add to build.zig:
const c_sources = [_][]const u8{
    // ... existing files ...
    "src/features/deploy.c",  // Your new file
};

πŸ§ͺ Development

Prerequisites

  • Zig (master branch) - Install via zvm
  • C compiler - For system libraries
  • NCurses - For TUI support
    • Ubuntu/Debian: sudo apt-get install libncurses-dev
    • macOS: brew install ncurses
    • Fedora: sudo dnf install ncurses-devel

Development Environment

This template provides several tools to enhance your development experience:

  • Devcontainer Support - Pre-configured development environment with all dependencies
  • VS Code Settings - Opinionated settings for C/Zig development
  • Pre-commit Hooks - Automated code quality checks before commits
  • Tasks Configuration - Predefined build and test tasks for VS Code
  • Debug Configuration - Ready-to-use debugging setup for VS Code

Commands

# Build
zig build                    # Debug build
zig build -Doptimize=ReleaseSafe  # Release build

# Test
zig build test              # Run all tests

# Clean
zig build clean             # Remove build artifacts

# Format
zig fmt build.zig          # Format build file

Configuration

Your app supports config from multiple sources:

  1. CLI arguments (highest priority)
  2. Environment variables
  3. Config file (~/.config/yourapp/config.json)
  4. Defaults

πŸ“š Documentation

Getting Started

Developer Resources

Examples & Demos

Project Information

πŸ€” Why This Stack?

  • C23 - Latest features: typeof, _BitInt, better type safety
  • Zig Build - Superior to Make/CMake, built-in cross-compilation
  • Aro Compiler - Better C23 support than most system compilers
  • Minimal Dependencies - Just Zig and libc, no complex toolchains

πŸ†˜ Getting Help

Template Issues

For problems with the template itself:

Your Project Issues

For issues with your generated project:

🌟 Projects Using This Template

Using this template? Add your project!

πŸ“„ License

This template is MIT licensed. See LICENSE for details.

When you use this template, you can choose any license for your project.


Ready to build your CLI app?

Use this template

Made with ❀️ by the open source community

About

Modern C23 CLI application starter with Zig build system, NCurses TUI support, and comprehensive project structure

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published