diff options
| author | 2023-12-13 08:53:06 +0100 | |
|---|---|---|
| committer | 2023-12-13 08:53:06 +0100 | |
| commit | feffdff4094ea3927eb3880b46b65e700f1e86fb (patch) | |
| tree | 071a86610548ebed5b8bec0617cf79cbeeee65fd /example/simple-ex.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/simple-ex.zig')
| -rw-r--r-- | example/simple-ex.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/example/simple-ex.zig b/example/simple-ex.zig index dd5d929..436d058 100644 --- a/example/simple-ex.zig +++ b/example/simple-ex.zig | |||
| @@ -6,6 +6,9 @@ const io = std.io; | |||
| 6 | const process = std.process; | 6 | const process = std.process; |
| 7 | 7 | ||
| 8 | pub fn main() !void { | 8 | pub fn main() !void { |
| 9 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | ||
| 10 | defer _ = gpa.deinit(); | ||
| 11 | |||
| 9 | // First we specify what parameters our program can take. | 12 | // First we specify what parameters our program can take. |
| 10 | // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)` | 13 | // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)` |
| 11 | const params = comptime clap.parseParamsComptime( | 14 | const params = comptime clap.parseParamsComptime( |
| @@ -30,6 +33,7 @@ pub fn main() !void { | |||
| 30 | var diag = clap.Diagnostic{}; | 33 | var diag = clap.Diagnostic{}; |
| 31 | var res = clap.parse(clap.Help, ¶ms, parsers, .{ | 34 | var res = clap.parse(clap.Help, ¶ms, parsers, .{ |
| 32 | .diagnostic = &diag, | 35 | .diagnostic = &diag, |
| 36 | .allocator = gpa.allocator(), | ||
| 33 | }) catch |err| { | 37 | }) catch |err| { |
| 34 | diag.report(io.getStdErr().writer(), err) catch {}; | 38 | diag.report(io.getStdErr().writer(), err) catch {}; |
| 35 | return err; | 39 | return err; |