summaryrefslogtreecommitdiff
path: root/example/help.zig
diff options
context:
space:
mode:
authorGravatar Jimmi HC2019-06-21 19:15:32 +0200
committerGravatar Jimmi HC2019-06-21 19:15:32 +0200
commit56e7be2835311888ef43f403e5d6bc2118c953fe (patch)
treea700e966b79ec441f8936c667bd325e37c4a61dc /example/help.zig
parentupdated to newest version of zig (diff)
downloadzig-clap-56e7be2835311888ef43f403e5d6bc2118c953fe.tar.gz
zig-clap-56e7be2835311888ef43f403e5d6bc2118c953fe.tar.xz
zig-clap-56e7be2835311888ef43f403e5d6bc2118c953fe.zip
Embed examples in README during build
fixes #11
Diffstat (limited to '')
-rw-r--r--example/help.zig25
1 files changed, 25 insertions, 0 deletions
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 @@
1const std = @import("std");
2const clap = @import("clap");
3
4pub fn main() !void {
5 const stderr_file = try std.io.getStdErr();
6 var stderr_out_stream = stderr_file.outStream();
7 const stderr = &stderr_out_stream.stream;
8
9 // clap.help is a function that can print a simple help message, given a
10 // slice of Param([]const u8). There is also a helpEx, which can print a
11 // help message for any Param, but it is more verbose to call.
12 try clap.help(
13 stderr,
14 [_]clap.Param([]const u8){
15 clap.Param([]const u8){
16 .id = "Display this help and exit.",
17 .names = clap.Names{ .short = 'h', .long = "help" },
18 },
19 clap.Param([]const u8){
20 .id = "Output version information and exit.",
21 .names = clap.Names{ .short = 'v', .long = "version" },
22 },
23 },
24 );
25}