summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2023-04-02 22:28:09 +0300
committerGravatar Uko Kokņevičs2023-04-02 22:30:53 +0300
commit06a9ac758c3c201625cbc17d3ccc0f8eea19cdf5 (patch)
tree1d8261677108400367497a1adec01135e18ad6f5 /src/main.zig
parentActually use my zig-curl instead of zelda. (diff)
downloadzup-06a9ac758c3c201625cbc17d3ccc0f8eea19cdf5.tar.gz
zup-06a9ac758c3c201625cbc17d3ccc0f8eea19cdf5.tar.xz
zup-06a9ac758c3c201625cbc17d3ccc0f8eea19cdf5.zip
Update to latest zig
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/main.zig b/src/main.zig
index 197a224..93356d6 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -73,25 +73,19 @@ fn dispatch(
73 comptime default_fn: anytype, 73 comptime default_fn: anytype,
74 args: anytype, 74 args: anytype,
75) !void { 75) !void {
76 // TODO: This can still be improved, currently we're looping through all possible values, it could be somehow made 76 // TODO: This can still be improved, currently we're looping through all
77 // into a switch. 77 // possible values, it could be somehow made into a switch.
78 const cmd_enum = CommandMap.get(cmd) orelse return @call(.{}, default_fn, args); 78 const cmd_enum = CommandMap.get(cmd) orelse return @call(.auto, default_fn, args);
79 const commands = @typeInfo(Command).Enum.fields; 79 const commands = @typeInfo(Command).Enum.fields;
80 inline for (commands) |command| { 80 inline for (commands) |command| {
81 if (@enumToInt(cmd_enum) == command.value) { 81 if (@enumToInt(cmd_enum) == command.value) {
82 // TODO: zig-bug it cries about modifying a constant if
83 // I just write `return @call(.{}, fun, args);`
84 const fun = @field(@field(@This(), command.name), fn_name); 82 const fun = @field(@field(@This(), command.name), fn_name);
85 return call(fun, args); 83 return @call(.auto, fun, args);
86 } 84 }
87 } 85 }
88 unreachable; 86 unreachable;
89} 87}
90 88
91inline fn call(fun: anytype, args: anytype) !void {
92 return @call(.{}, fun, args);
93}
94
95fn unknownCmd(cmd: []const u8, _: Config, _: *ArgIterator) !void { 89fn unknownCmd(cmd: []const u8, _: Config, _: *ArgIterator) !void {
96 std.log.err("Unknown subcommand: {s}", .{cmd}); 90 std.log.err("Unknown subcommand: {s}", .{cmd});
97 return error.ArgError; 91 return error.ArgError;