From cc056cf4232721b62b76428d1ada447eecd98421 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Thu, 5 Mar 2020 23:24:36 +0100 Subject: Add clap.usage --- example/usage.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 example/usage.zig (limited to 'example/usage.zig') diff --git a/example/usage.zig b/example/usage.zig new file mode 100644 index 0000000..734d741 --- /dev/null +++ b/example/usage.zig @@ -0,0 +1,20 @@ +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.usage is a function that can print a simple usage message, given a + // slice of Param(Help). There is also a usageEx, which can print a + // usage message for any Param, but it is more verbose to call. + try clap.usage( + stderr, + comptime [_]clap.Param(clap.Help){ + clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, + clap.parseParam("-v, --version Output version information and exit.") catch unreachable, + clap.parseParam(" --value Output version information and exit.") catch unreachable, + }, + ); +} -- cgit v1.2.3