diff options
| author | 2023-12-13 08:53:06 +0100 | |
|---|---|---|
| committer | 2023-12-13 08:59:38 +0100 | |
| commit | cf3a4e763831dd7e0845fef4f209f5c780eda375 (patch) | |
| tree | 071a86610548ebed5b8bec0617cf79cbeeee65fd /example/help.zig | |
| parent | Fix short only params not getting fields in `Arguments` (diff) | |
| download | zig-clap-cf3a4e763831dd7e0845fef4f209f5c780eda375.tar.gz zig-clap-cf3a4e763831dd7e0845fef4f209f5c780eda375.tar.xz zig-clap-cf3a4e763831dd7e0845fef4f209f5c780eda375.zip | |
Remove the default allocator from `ParseOptions`
fixes #111
Diffstat (limited to 'example/help.zig')
| -rw-r--r-- | example/help.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/example/help.zig b/example/help.zig index e83ae44..2f063c5 100644 --- a/example/help.zig +++ b/example/help.zig | |||
| @@ -2,13 +2,18 @@ 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. |
| 8 | \\ | 11 | \\ |
| 9 | ); | 12 | ); |
| 10 | 13 | ||
| 11 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); | 14 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ |
| 15 | .allocator = gpa.allocator(), | ||
| 16 | }); | ||
| 12 | defer res.deinit(); | 17 | defer res.deinit(); |
| 13 | 18 | ||
| 14 | // `clap.help` is a function that can print a simple help message. It can print any `Param` | 19 | // `clap.help` is a function that can print a simple help message. It can print any `Param` |