diff options
| author | 2019-06-21 19:15:32 +0200 | |
|---|---|---|
| committer | 2019-06-21 19:15:32 +0200 | |
| commit | 56e7be2835311888ef43f403e5d6bc2118c953fe (patch) | |
| tree | a700e966b79ec441f8936c667bd325e37c4a61dc /example/comptime-clap.zig | |
| parent | updated to newest version of zig (diff) | |
| download | zig-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/comptime-clap.zig | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/example/comptime-clap.zig b/example/comptime-clap.zig index 935381f..695fa62 100644 --- a/example/comptime-clap.zig +++ b/example/comptime-clap.zig | |||
| @@ -13,7 +13,7 @@ pub fn main() !void { | |||
| 13 | defer direct_allocator.deinit(); | 13 | defer direct_allocator.deinit(); |
| 14 | 14 | ||
| 15 | // First we specify what parameters our program can take. | 15 | // First we specify what parameters our program can take. |
| 16 | const params = comptime [_]clap.Param([]const u8){ | 16 | const params = [_]clap.Param([]const u8){ |
| 17 | clap.Param([]const u8){ | 17 | clap.Param([]const u8){ |
| 18 | .id = "Display this help and exit.", | 18 | .id = "Display this help and exit.", |
| 19 | .names = clap.Names{ .short = 'h', .long = "help" }, | 19 | .names = clap.Names{ .short = 'h', .long = "help" }, |
| @@ -41,11 +41,8 @@ pub fn main() !void { | |||
| 41 | var args = try clap.ComptimeClap([]const u8, params).parse(allocator, clap.args.OsIterator, &iter); | 41 | var args = try clap.ComptimeClap([]const u8, params).parse(allocator, clap.args.OsIterator, &iter); |
| 42 | defer args.deinit(); | 42 | defer args.deinit(); |
| 43 | 43 | ||
| 44 | // clap.help is a function that can print a simple help message, given a | ||
| 45 | // slice of Param([]const u8). There is also a helpEx, which can print a | ||
| 46 | // help message for any Param, but it is more verbose to call. | ||
| 47 | if (args.flag("--help")) | 44 | if (args.flag("--help")) |
| 48 | return try clap.help(stdout, params); | 45 | debug.warn("--help\n"); |
| 49 | if (args.option("--number")) |n| | 46 | if (args.option("--number")) |n| |
| 50 | debug.warn("--number = {}\n", n); | 47 | debug.warn("--number = {}\n", n); |
| 51 | for (args.positionals()) |pos| | 48 | for (args.positionals()) |pos| |