summaryrefslogtreecommitdiff
path: root/example/simple.zig
diff options
context:
space:
mode:
Diffstat (limited to 'example/simple.zig')
-rw-r--r--example/simple.zig12
1 files changed, 7 insertions, 5 deletions
diff --git a/example/simple.zig b/example/simple.zig
index 67313aa..a7772c6 100644
--- a/example/simple.zig
+++ b/example/simple.zig
@@ -1,6 +1,10 @@
1pub fn main() !void { 1pub 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 // First we specify what parameters our program can take. 9 // First we specify what parameters our program can take.
6 // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`. 10 // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`.
@@ -16,11 +20,9 @@ pub fn main() !void {
16 // This is optional. You can also pass `.{}` to `clap.parse` if you don't 20 // This is optional. You can also pass `.{}` to `clap.parse` if you don't
17 // care about the extra information `Diagnostics` provides. 21 // care about the extra information `Diagnostics` provides.
18 var diag = clap.Diagnostic{}; 22 var diag = clap.Diagnostic{};
19 var threaded: std.Io.Threaded = .init_single_threaded;
20 const io: std.Io = threaded.io();
21 var res = clap.parse(clap.Help, &params, clap.parsers.default, .{ 23 var res = clap.parse(clap.Help, &params, clap.parsers.default, .{
22 .diagnostic = &diag, 24 .diagnostic = &diag,
23 .allocator = gpa.allocator(), 25 .allocator = gpa,
24 }) catch |err| { 26 }) catch |err| {
25 // Report useful error and exit. 27 // Report useful error and exit.
26 try diag.reportToFile(io, .stderr(), err); 28 try diag.reportToFile(io, .stderr(), err);