Adds demo.

This commit is contained in:
Felix (xq) Queißner 2020-03-04 22:37:11 +01:00
parent 6d643cdaec
commit 1d1179ee9e

35
demo.zig Normal file
View File

@ -0,0 +1,35 @@
const std = @import("std");
const argsParser = @import("args");
pub fn main() !void {
var args = std.process.args();
var argsAllocator = std.heap.direct_allocator;
const exeName = try (args.next(argsAllocator) orelse {
try std.io.getStdErr().outStream().stream.write("Failed to get executable name from the argument list!\n");
return;
});
defer argsAllocator.free(exeName);
const options = try argsParser.parse(struct {
output: ?[]const u8 = null,
@"with-offset": bool = false,
@"with-hexdump": bool = false,
@"intermix-source": bool = false,
numberOfBytes: ?i32 = null,
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});
}
}