Kingrashy12/ziglet
A lightweight command-line interface (CLI) builder.
Ziglet is a lightweight command-line interface (CLI) builder. It lets you effortlessly define custom commands and execute them using Ziglet's core executeCommand
functionality—giving you a flexible and blazing-fast CLI tool tailored to your needs.
executeCommand
built into Zigletzig fetch --save git+https://github.com/Kingrashy12/ziglet
build.zig
: // Add the ziglet dependency
const ziglet_dep = b.dependency("ziglet", .{
.target = target,
.optimize = optimize,
});
// Add the ziglet module to the executable
exe.root_module.addImport("ziglet", ziglet_dep.module("ziglet"));
const std = @import("std");
const ziglet = @import("ziglet");
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
var commander = try ziglet.Commander.init(allocator, "my-cli", "0.1.0", null);
defer commander.deinit();
// Define a simple command
try commander.addCommand("greet", "Say Hello", greetFn, null);
try commander.checkArgs();
try commander.executeCommand();
}
// The function to execute
fn greetFn(self: *ziglet.Commander) !void {
std.debug.print("Hello from {s}!\n", .{self.name});
}
Want to make Ziglet even snappier? Feel free to open issues, suggest features, or submit pull requests. Let’s build something sharp together.
MIT – free to use, modify, and share.