sammyjoyce/c23-cli-template
Modern C23 CLI application starter with Zig build system, NCurses TUI support, and comprehensive project structure
5204da998cb6d966bbb39d3ccf687b6b008cebc6
Use this template โข View Demo โข Report Bug
gh repo create my-cli \
--template sammyjoyce/c23-cli-template \
--public \
--clone
# 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
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
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
The template automatically:
myapp
with your project nameCheck the Actions tab to see progress.
Edit src/main.c
:
if (strcmp(command, "deploy") == 0) {
printf("Deploying application...\n");
// Your deployment logic
return APP_SUCCESS;
}
Edit src/cli/help.c
to describe your commands.
.c
file in src/
build.zig
:const c_sources = [_][]const u8{
// ... existing files ...
"src/features/deploy.c", // Your new file
};
sudo apt-get install libncurses-dev
brew install ncurses
sudo dnf install ncurses-devel
This template provides several tools to enhance your development experience:
# 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
Your app supports config from multiple sources:
~/.config/yourapp/config.json
)typeof
, _BitInt
, better type safetyFor problems with the template itself:
For issues with your generated project:
Using this template? Add your project!
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?
Made with โค๏ธ by the open source community