diff options
Diffstat (limited to 'example/usage.zig')
| -rw-r--r-- | example/usage.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/example/usage.zig b/example/usage.zig index 333536b..a773dd2 100644 --- a/example/usage.zig +++ b/example/usage.zig | |||
| @@ -2,6 +2,9 @@ const clap = @import("clap"); | |||
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | 3 | ||
| 4 | pub fn main() !void { | 4 | pub fn main() !void { |
| 5 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | ||
| 6 | defer _ = gpa.deinit(); | ||
| 7 | |||
| 5 | const params = comptime clap.parseParamsComptime( | 8 | const params = comptime clap.parseParamsComptime( |
| 6 | \\-h, --help Display this help and exit. | 9 | \\-h, --help Display this help and exit. |
| 7 | \\-v, --version Output version information and exit. | 10 | \\-v, --version Output version information and exit. |
| @@ -9,7 +12,9 @@ pub fn main() !void { | |||
| 9 | \\ | 12 | \\ |
| 10 | ); | 13 | ); |
| 11 | 14 | ||
| 12 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); | 15 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ |
| 16 | .allocator = gpa.allocator(), | ||
| 17 | }); | ||
| 13 | defer res.deinit(); | 18 | defer res.deinit(); |
| 14 | 19 | ||
| 15 | // `clap.usage` is a function that can print a simple help message. It can print any `Param` | 20 | // `clap.usage` is a function that can print a simple help message. It can print any `Param` |