diff options
Diffstat (limited to 'example/simple.zig')
| -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 {}; |