Compare commits
2 Commits
1bb3659df6
...
f8018854be
Author | SHA1 | Date | |
---|---|---|---|
f8018854be | |||
fae4b430ab |
Submodule lib/SDL.zig updated: 021b71dde4...47b8ab43f3
Submodule lib/zig-clap updated: a2af4a9267...ac5f46541c
29
src/main.zig
29
src/main.zig
@@ -32,26 +32,25 @@ pub fn main() anyerror!void {
|
|||||||
const alloc = gpa.allocator();
|
const alloc = gpa.allocator();
|
||||||
defer std.debug.assert(!gpa.deinit());
|
defer std.debug.assert(!gpa.deinit());
|
||||||
|
|
||||||
// Parse CLI Arguments
|
// CLI Arguments
|
||||||
const params = comptime [_]clap.Param(clap.Help){
|
const params = comptime clap.parseParamsComptime(
|
||||||
clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
|
\\-h, --help Display this help and exit.
|
||||||
clap.parseParam("-b, --bios <PATH> Optional Path to GBA BIOS ROM. ") catch unreachable,
|
\\-b, --bios <str> Optional path to a GBA BIOS ROM.
|
||||||
clap.parseParam("<PATH> Path to GBA GamePak ROM ") catch unreachable,
|
\\<str> Path to the GBA GamePak ROM
|
||||||
};
|
\\
|
||||||
|
);
|
||||||
|
|
||||||
var args = try clap.parse(clap.Help, ¶ms, .{});
|
var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{});
|
||||||
defer args.deinit();
|
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();
|
const stderr = std.io.getStdErr();
|
||||||
defer stderr.close();
|
defer stderr.close();
|
||||||
|
|
||||||
const rom_path = switch (positionals.len) {
|
if (res.args.help) return clap.help(stderr.writer(), clap.Help, ¶ms, .{});
|
||||||
1 => positionals[0],
|
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 => {
|
0 => {
|
||||||
try stderr.writeAll("ZBA requires a positional path to a GamePak ROM.\n");
|
try stderr.writeAll("ZBA requires a positional path to a GamePak ROM.\n");
|
||||||
return CliError.InsufficientOptions;
|
return CliError.InsufficientOptions;
|
||||||
|
Reference in New Issue
Block a user