diff options
Diffstat (limited to 'example/simple-ex.zig')
| -rw-r--r-- | example/simple-ex.zig | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/example/simple-ex.zig b/example/simple-ex.zig index 0d90b69..c35b867 100644 --- a/example/simple-ex.zig +++ b/example/simple-ex.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( |
| @@ -28,15 +21,15 @@ pub fn main() !void { | |||
| 28 | }; | 21 | }; |
| 29 | 22 | ||
| 30 | var diag = clap.Diagnostic{}; | 23 | var diag = clap.Diagnostic{}; |
| 31 | var res = clap.parse(clap.Help, ¶ms, parsers, .{ | 24 | var res = clap.parse(clap.Help, ¶ms, parsers, init.minimal.args, .{ |
| 32 | .diagnostic = &diag, | 25 | .diagnostic = &diag, |
| 33 | .allocator = gpa, | 26 | .allocator = init.gpa, |
| 34 | // The assignment separator can be configured. `--number=1` and `--number:1` is now | 27 | // The assignment separator can be configured. `--number=1` and `--number:1` is now |
| 35 | // allowed. | 28 | // allowed. |
| 36 | .assignment_separators = "=:", | 29 | .assignment_separators = "=:", |
| 37 | }) catch |err| { | 30 | }) catch |err| { |
| 38 | // Report useful error and exit. | 31 | // Report useful error and exit. |
| 39 | try diag.reportToFile(io, .stderr(), err); | 32 | try diag.reportToFile(init.io, .stderr(), err); |
| 40 | return err; | 33 | return err; |
| 41 | }; | 34 | }; |
| 42 | defer res.deinit(); | 35 | defer res.deinit(); |