diff options
| author | 2023-12-13 08:53:06 +0100 | |
|---|---|---|
| committer | 2023-12-13 08:53:06 +0100 | |
| commit | feffdff4094ea3927eb3880b46b65e700f1e86fb (patch) | |
| tree | 071a86610548ebed5b8bec0617cf79cbeeee65fd /example/usage.zig | |
| parent | Fix short only params not getting fields in `Arguments` (diff) | |
| download | zig-clap-no-default-allocator.tar.gz zig-clap-no-default-allocator.tar.xz zig-clap-no-default-allocator.zip | |
Remove the default allocator from `ParseOptions`no-default-allocator
fixes #111
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` |