github zig-args 镜像仓库
Go to file
Felix (xq) Queißner 94c96afcdd Adds demo.
2020-03-04 22:38:29 +01:00
args.zig Moves source code from NativeLola. 2020-03-04 22:36:06 +01:00
demo.zig Adds demo. 2020-03-04 22:38:29 +01:00
LICENSE Initial commit 2020-03-04 22:34:01 +01:00
README.md Adds demo. 2020-03-04 22:38:29 +01:00

zig-args

Simple-to-use argument parser with struct-based config

const options = try argsParser.parse(struct {
    // This declares long options for double hyphen
    output: ?[]const u8 = null,
    @"with-offset": bool = false,
    @"with-hexdump": bool = false,
    @"intermix-source": bool = false,
    numberOfBytes: ?i32 = null,

    // This declares short-hand options for single hyphen
    pub const shorthands = .{
        .S = "intermix-source",
        .b = "with-hexdump",
        .O = "with-offset",
        .o = "output",
    };
}, &args, argsAllocator);
defer options.deinit();

std.debug.warn("parsed result:\n{}\npositionals:\n", .{options.options});
for (options.args) |arg| {
    std.debug.warn("\t{}\n", .{arg});
}