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