From 56e7be2835311888ef43f403e5d6bc2118c953fe Mon Sep 17 00:00:00 2001 From: Jimmi HC Date: Fri, 21 Jun 2019 19:15:32 +0200 Subject: Embed examples in README during build fixes #11 --- example/help.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 example/help.zig (limited to 'example/help.zig') diff --git a/example/help.zig b/example/help.zig new file mode 100644 index 0000000..35c0258 --- /dev/null +++ b/example/help.zig @@ -0,0 +1,25 @@ +const std = @import("std"); +const clap = @import("clap"); + +pub fn main() !void { + const stderr_file = try std.io.getStdErr(); + var stderr_out_stream = stderr_file.outStream(); + const stderr = &stderr_out_stream.stream; + + // clap.help is a function that can print a simple help message, given a + // slice of Param([]const u8). There is also a helpEx, which can print a + // help message for any Param, but it is more verbose to call. + try clap.help( + stderr, + [_]clap.Param([]const u8){ + clap.Param([]const u8){ + .id = "Display this help and exit.", + .names = clap.Names{ .short = 'h', .long = "help" }, + }, + clap.Param([]const u8){ + .id = "Output version information and exit.", + .names = clap.Names{ .short = 'v', .long = "version" }, + }, + }, + ); +} -- cgit v1.2.3