diff options
| author | 2021-05-08 18:08:52 +0200 | |
|---|---|---|
| committer | 2021-05-08 18:08:52 +0200 | |
| commit | 4c14bfd5188bb61d7076bc33fccbcc6a5e9dac01 (patch) | |
| tree | 8f5267e4da9bbc14bd595697797457911d4b3081 /example/simple.zig | |
| parent | Refactor Diagnostic (and others) into a ParseOption struct (diff) | |
| download | zig-clap-4c14bfd5188bb61d7076bc33fccbcc6a5e9dac01.tar.gz zig-clap-4c14bfd5188bb61d7076bc33fccbcc6a5e9dac01.tar.xz zig-clap-4c14bfd5188bb61d7076bc33fccbcc6a5e9dac01.zip | |
Modernize codebase
* Better naming for variables
* Follow naming style of enums
* Use `writer()` instead of `outStream()`
* Change many initializers to be a one liner
* Don't explicitly initialize fields to their default value
Diffstat (limited to 'example/simple.zig')
| -rw-r--r-- | example/simple.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/example/simple.zig b/example/simple.zig index 392dca3..69473fa 100644 --- a/example/simple.zig +++ b/example/simple.zig | |||
| @@ -2,6 +2,7 @@ const clap = @import("clap"); | |||
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | 3 | ||
| 4 | const debug = std.debug; | 4 | const debug = std.debug; |
| 5 | const io = std.io; | ||
| 5 | 6 | ||
| 6 | pub fn main() !void { | 7 | pub fn main() !void { |
| 7 | // First we specify what parameters our program can take. | 8 | // First we specify what parameters our program can take. |
| @@ -19,7 +20,7 @@ pub fn main() !void { | |||
| 19 | var diag = clap.Diagnostic{}; | 20 | var diag = clap.Diagnostic{}; |
| 20 | var args = clap.parse(clap.Help, ¶ms, .{ .diagnostic = &diag }) catch |err| { | 21 | var args = clap.parse(clap.Help, ¶ms, .{ .diagnostic = &diag }) catch |err| { |
| 21 | // Report useful error and exit | 22 | // Report useful error and exit |
| 22 | diag.report(std.io.getStdErr().outStream(), err) catch {}; | 23 | diag.report(io.getStdErr().writer(), err) catch {}; |
| 23 | return err; | 24 | return err; |
| 24 | }; | 25 | }; |
| 25 | defer args.deinit(); | 26 | defer args.deinit(); |