https://github.com/sammyjoyce/c23-cli-template
Modern C23 CLI application starter with Zig build system, NCurses TUI support, and comprehensive project structure
https://github.com/sammyjoyce/c23-cli-template
c c23 cli cli-app command-line ncurses starter-template template tui zig zig-build
Last synced: 25 days ago
JSON representation
Modern C23 CLI application starter with Zig build system, NCurses TUI support, and comprehensive project structure
- Host: GitHub
- URL: https://github.com/sammyjoyce/c23-cli-template
- Owner: sammyjoyce
- License: other
- Created: 2025-07-27T04:22:50.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-27T06:29:22.000Z (11 months ago)
- Last Synced: 2025-07-27T06:29:55.521Z (11 months ago)
- Topics: c, c23, cli, cli-app, command-line, ncurses, starter-template, template, tui, zig, zig-build
- Language: C
- Size: 110 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# CLI Starter Template - C23 + Zig ๐
[](https://github.com/sammyjoyce/c23-cli-template)
[](https://github.com/sammyjoyce/c23-cli-template/blob/main/LICENSE)
[](https://github.com/sammyjoyce/c23-cli-template/actions/workflows/ci.yaml)
[](https://codecov.io/gh/sammyjoyce/c23-cli-template)
[](https://ziglang.org/)
[](https://github.com/sammyjoyce/c23-cli-template/actions/workflows/ci.yaml)
[](https://github.com/sammyjoyce/c23-cli-template/actions/workflows/ci.yaml)
[](https://securityscorecards.dev/viewer/?uri=github.com/sammyjoyce/c23-cli-template)
## A modern C23 CLI application starter template with Zig build system
[Use this template](https://github.com/sammyjoyce/c23-cli-template/generate) โข [View Demo](https://github.com/sammyjoyce/c23-cli-template) โข [Report Bug](https://github.com/sammyjoyce/c23-cli-template/issues)
---
## โจ 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"](https://github.com/sammyjoyce/c23-cli-template/generate)
2. Name your repository
3. Click "Create repository"
### Option 2: GitHub CLI
```bash
gh repo create my-cli \
--template sammyjoyce/c23-cli-template \
--public \
--clone
```
### Build & Run
```bash
# 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
```text
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:
```bash
# 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`:
```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`:
```zig
const c_sources = [_][]const u8{
// ... existing files ...
"src/features/deploy.c", // Your new file
};
```
## ๐งช Development
### Prerequisites
- **Zig** (master branch) - Install via [zvm](https://github.com/tristanisham/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
```bash
# 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
- ๐ [**Using This Template**](/.template/TEMPLATE_USAGE.md) - Detailed setup guide
- ๐ [**Quick Start Guide**](#-quick-start) - Get up and running quickly
- ๐ง [**Installation**](#-installation) - Platform-specific instructions
### Developer Resources
- ๐๏ธ [**Architecture Overview**](docs/ARCHITECTURE.md) - System design and module structure
- โก [**Zig Primer for C Developers**](docs/ZIG_PRIMER.md) - Understanding the build system
- ๐ค [**Contributing Guide**](CONTRIBUTING.md) - How to contribute to the project
- ๐งช [**Advanced Usage Examples**](examples/advanced-usage.md) - Piping, scripting, and integration
### Examples & Demos
- ๐ [**Adding Commands**](examples/adding-a-command.md) - Extend the CLI
- ๐จ [**Custom TUI Components**](examples/custom-tui.md) - Build interactive interfaces
- โ๏ธ [**Configuration Guide**](examples/config.json) - Config file examples
- ๐ฌ [**Demo Gallery**](docs/demos/README.md) - Animated demonstrations
### Project Information
- ๐ก๏ธ [**Security Policy**](SECURITY.md) - Reporting vulnerabilities
- ๐ [**Code of Conduct**](CODE_OF_CONDUCT.md) - Community guidelines
- ๐ [**Changelog**](CHANGELOG.md) - Version history
- ๐ [**License**](LICENSE) - MIT License
## ๐ค 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:
- Check [existing issues](https://github.com/sammyjoyce/c23-cli-template/issues)
- Create a new issue
- Read [template support](/.template/TEMPLATE_SUPPORT.md)
### Your Project Issues
For issues with your generated project:
- Use your own repository's issues
- Check Zig [documentation](https://ziglang.org/documentation/)
- See C23 [reference](https://en.cppreference.com/w/c/23)
## ๐ Projects Using This Template
> Using this template? [Add your project!](https://github.com/sammyjoyce/c23-cli-template/edit/main/README.md)
- [Example CLI](https://github.com/example/cli) - Description
- Your project here!
## ๐ License
This template is MIT licensed. See [LICENSE](LICENSE) for details.
When you use this template, you can choose any license for your project.
---
**Ready to build your CLI app?**
[](https://github.com/sammyjoyce/c23-cli-template/generate)
Made with โค๏ธ by the open source community