diff options
Diffstat (limited to 'example/usage.zig')
| -rw-r--r-- | example/usage.zig | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/example/usage.zig b/example/usage.zig index c1440b9..2d51cc4 100644 --- a/example/usage.zig +++ b/example/usage.zig | |||
| @@ -1,6 +1,10 @@ | |||
| 1 | pub fn main() !void { | 1 | pub fn main() !void { |
| 2 | var gpa = std.heap.DebugAllocator(.{}){}; | 2 | var gpa_state = std.heap.DebugAllocator(.{}){}; |
| 3 | defer _ = gpa.deinit(); | 3 | const gpa = gpa_state.allocator(); |
| 4 | defer _ = gpa_state.deinit(); | ||
| 5 | |||
| 6 | var threaded: std.Io.Threaded = .init_single_threaded; | ||
| 7 | const io: std.Io = threaded.io(); | ||
| 4 | 8 | ||
| 5 | const params = comptime clap.parseParamsComptime( | 9 | const params = comptime clap.parseParamsComptime( |
| 6 | \\-h, --help Display this help and exit. | 10 | \\-h, --help Display this help and exit. |
| @@ -9,14 +13,9 @@ pub fn main() !void { | |||
| 9 | \\ | 13 | \\ |
| 10 | ); | 14 | ); |
| 11 | 15 | ||
| 12 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ | 16 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ .allocator = gpa }); |
| 13 | .allocator = gpa.allocator(), | ||
| 14 | }); | ||
| 15 | defer res.deinit(); | 17 | defer res.deinit(); |
| 16 | 18 | ||
| 17 | var threaded: std.Io.Threaded = .init_single_threaded; | ||
| 18 | const io: std.Io = threaded.io(); | ||
| 19 | |||
| 20 | // `clap.usageToFile` is a function that can print a simple usage string. It can print any | 19 | // `clap.usageToFile` is a function that can print a simple usage string. It can print any |
| 21 | // `Param` where `Id` has a `value` method (`Param(Help)` is one such parameter). | 20 | // `Param` where `Id` has a `value` method (`Param(Help)` is one such parameter). |
| 22 | if (res.args.help != 0) | 21 | if (res.args.help != 0) |