From fae4b430ab2d1b637cfeda51678d720211f78d08 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 7 Apr 2022 15:58:47 -0300 Subject: [PATCH] chore: update dependencies --- lib/SDL.zig | 2 +- lib/zig-clap | 2 +- src/main.zig | 29 ++++++++++++++--------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/SDL.zig b/lib/SDL.zig index 021b71d..47b8ab4 160000 --- a/lib/SDL.zig +++ b/lib/SDL.zig @@ -1 +1 @@ -Subproject commit 021b71dde4774364b9da2418e3de2c42499c605d +Subproject commit 47b8ab43f3cf8362b266613e55704c8ae38e9bc6 diff --git a/lib/zig-clap b/lib/zig-clap index a2af4a9..ac5f465 160000 --- a/lib/zig-clap +++ b/lib/zig-clap @@ -1 +1 @@ -Subproject commit a2af4a9267c547ec0f91ea1a84b2a50760ca5483 +Subproject commit ac5f46541ca47d3db9df0fcef3cc61731adaefab diff --git a/src/main.zig b/src/main.zig index 32ce529..0b9e224 100644 --- a/src/main.zig +++ b/src/main.zig @@ -32,26 +32,25 @@ pub fn main() anyerror!void { const alloc = gpa.allocator(); defer std.debug.assert(!gpa.deinit()); - // Parse CLI Arguments - const params = comptime [_]clap.Param(clap.Help){ - clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, - clap.parseParam("-b, --bios Optional Path to GBA BIOS ROM. ") catch unreachable, - clap.parseParam(" Path to GBA GamePak ROM ") catch unreachable, - }; + // CLI Arguments + const params = comptime clap.parseParamsComptime( + \\-h, --help Display this help and exit. + \\-b, --bios Optional path to a GBA BIOS ROM. + \\ Path to the GBA GamePak ROM + \\ + ); - var args = try clap.parse(clap.Help, ¶ms, .{}); - defer args.deinit(); + var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); + defer res.deinit(); - if (args.flag("--help")) return clap.help(std.io.getStdErr().writer(), ¶ms); - - const bios_path: ?[]const u8 = if (args.option("--bios")) |p| p else null; - - const positionals = args.positionals(); const stderr = std.io.getStdErr(); defer stderr.close(); - const rom_path = switch (positionals.len) { - 1 => positionals[0], + if (res.args.help) return clap.help(stderr.writer(), clap.Help, ¶ms, .{}); + const bios_path: ?[]const u8 = if (res.args.bios) |p| p else null; + + const rom_path = switch (res.positionals.len) { + 1 => res.positionals[0], 0 => { try stderr.writeAll("ZBA requires a positional path to a GamePak ROM.\n"); return CliError.InsufficientOptions;