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.zig | |
| parent | Fix short only params not getting fields in `Arguments` (diff) | |
| download | zig-clap-feffdff4094ea3927eb3880b46b65e700f1e86fb.tar.gz zig-clap-feffdff4094ea3927eb3880b46b65e700f1e86fb.tar.xz zig-clap-feffdff4094ea3927eb3880b46b65e700f1e86fb.zip | |
Remove the default allocator from `ParseOptions`no-default-allocator
fixes #111
Diffstat (limited to '')
| -rw-r--r-- | example/simple.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/example/simple.zig b/example/simple.zig index 429f095..a7207c7 100644 --- a/example/simple.zig +++ b/example/simple.zig | |||
| @@ -5,6 +5,9 @@ const debug = std.debug; | |||
| 5 | const io = std.io; | 5 | const io = std.io; |
| 6 | 6 | ||
| 7 | pub fn main() !void { | 7 | pub fn main() !void { |
| 8 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | ||
| 9 | defer _ = gpa.deinit(); | ||
| 10 | |||
| 8 | // First we specify what parameters our program can take. | 11 | // First we specify what parameters our program can take. |
| 9 | // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)` | 12 | // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)` |
| 10 | const params = comptime clap.parseParamsComptime( | 13 | const params = comptime clap.parseParamsComptime( |
| @@ -21,6 +24,7 @@ pub fn main() !void { | |||
| 21 | var diag = clap.Diagnostic{}; | 24 | var diag = clap.Diagnostic{}; |
| 22 | var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ | 25 | var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ |
| 23 | .diagnostic = &diag, | 26 | .diagnostic = &diag, |
| 27 | .allocator = gpa.allocator(), | ||
| 24 | }) catch |err| { | 28 | }) catch |err| { |
| 25 | // Report useful error and exit | 29 | // Report useful error and exit |
| 26 | diag.report(io.getStdErr().writer(), err) catch {}; | 30 | diag.report(io.getStdErr().writer(), err) catch {}; |