summaryrefslogtreecommitdiff
path: root/example/usage.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2023-12-13 08:53:06 +0100
committerGravatar Jimmi Holst Christensen2023-12-13 08:53:06 +0100
commitfeffdff4094ea3927eb3880b46b65e700f1e86fb (patch)
tree071a86610548ebed5b8bec0617cf79cbeeee65fd /example/usage.zig
parentFix short only params not getting fields in `Arguments` (diff)
downloadzig-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/usage.zig7
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");
2const std = @import("std"); 2const std = @import("std");
3 3
4pub fn main() !void { 4pub 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, &params, clap.parsers.default, .{}); 15 var res = try clap.parse(clap.Help, &params, 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`