diff options
Diffstat (limited to 'example/simple.zig')
| -rw-r--r-- | example/simple.zig | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/example/simple.zig b/example/simple.zig index a7772c6..7ed1d84 100644 --- a/example/simple.zig +++ b/example/simple.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 | // First we specify what parameters our program can take. | 2 | // First we specify what parameters our program can take. |
| 10 | // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`. | 3 | // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`. |
| 11 | const params = comptime clap.parseParamsComptime( | 4 | const params = comptime clap.parseParamsComptime( |
| @@ -20,12 +13,12 @@ pub fn main() !void { | |||
| 20 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't | 13 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't |
| 21 | // care about the extra information `Diagnostics` provides. | 14 | // care about the extra information `Diagnostics` provides. |
| 22 | var diag = clap.Diagnostic{}; | 15 | var diag = clap.Diagnostic{}; |
| 23 | var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ | 16 | var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, init.minimal.args, .{ |
| 24 | .diagnostic = &diag, | 17 | .diagnostic = &diag, |
| 25 | .allocator = gpa, | 18 | .allocator = init.gpa, |
| 26 | }) catch |err| { | 19 | }) catch |err| { |
| 27 | // Report useful error and exit. | 20 | // Report useful error and exit. |
| 28 | try diag.reportToFile(io, .stderr(), err); | 21 | try diag.reportToFile(init.io, .stderr(), err); |
| 29 | return err; | 22 | return err; |
| 30 | }; | 23 | }; |
| 31 | defer res.deinit(); | 24 | defer res.deinit(); |