Skip to content

Kingrashy12/ziglet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐣 Ziglet – Your Minimalist CLI Builder in Zig

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.

✨ Features

  • Add and organize custom commands with ease
  • Execute commands with executeCommand built into Ziglet
  • Minimal dependencies, maximum speed
  • Built in Zig for clarity, performance, and control

📚 How to Use

  1. Fetch the package:
zig fetch --save git+https://github.com/Kingrashy12/ziglet
  1. Add the module to your 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"));
  1. Import and use in your code:
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});
}

🤝 Contributing

Want to make Ziglet even snappier? Feel free to open issues, suggest features, or submit pull requests. Let’s build something sharp together.

📄 License

MIT – free to use, modify, and share.

About

A lightweight command-line interface (CLI) builder.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages