diff options
Diffstat (limited to 'example/help.zig')
| -rw-r--r-- | example/help.zig | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/example/help.zig b/example/help.zig index b07bc52..a41b261 100644 --- a/example/help.zig +++ b/example/help.zig | |||
| @@ -1,18 +1,11 @@ | |||
| 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. |
| 12 | \\ | 5 | \\ |
| 13 | ); | 6 | ); |
| 14 | 7 | ||
| 15 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ .allocator = gpa }); | 8 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, init.minimal.args, .{ .allocator = init.gpa }); |
| 16 | defer res.deinit(); | 9 | defer res.deinit(); |
| 17 | 10 | ||
| 18 | // `clap.help` is a function that can print a simple help message. It can print any `Param` | 11 | // `clap.help` is a function that can print a simple help message. It can print any `Param` |
| @@ -20,7 +13,7 @@ pub fn main() !void { | |||
| 20 | // The last argument contains options as to how `help` should print those parameters. Using | 13 | // The last argument contains options as to how `help` should print those parameters. Using |
| 21 | // `.{}` means the default options. | 14 | // `.{}` means the default options. |
| 22 | if (res.args.help != 0) | 15 | if (res.args.help != 0) |
| 23 | return clap.helpToFile(io, .stderr(), clap.Help, ¶ms, .{}); | 16 | return clap.helpToFile(init.io, .stderr(), clap.Help, ¶ms, .{}); |
| 24 | } | 17 | } |
| 25 | 18 | ||
| 26 | const clap = @import("clap"); | 19 | const clap = @import("clap"); |