| ... | @@ -49,7 +49,7 @@ const usage = | ... | @@ -49,7 +49,7 @@ const usage = |
| 49 | | 49 | |
| 50 | const Command = struct { | 50 | const Command = struct { |
| 51 | name: []const u8, | 51 | name: []const u8, |
| 52 | exec: fn (*Allocator, []const []const u8) anyerror!void, | 52 | exec: async fn (*Allocator, []const []const u8) anyerror!void, |
| 53 | }; | 53 | }; |
| 54 | | 54 | |
| 55 | pub fn main() !void { | 55 | pub fn main() !void { |
| ... | @@ -118,9 +118,12 @@ pub fn main() !void { | ... | @@ -118,9 +118,12 @@ pub fn main() !void { |
| 118 | }, | 118 | }, |
| 119 | }; | 119 | }; |
| 120 | | 120 | |
| 121 | for (commands) |command| { | 121 | inline for (commands) |command| { |
| 122 | if (mem.eql(u8, command.name, args[1])) { | 122 | if (mem.eql(u8, command.name, args[1])) { |
| 123 | return command.exec(allocator, args[2..]); | 123 | var frame = try allocator.create(@Frame(command.exec)); |
| | 124 | defer allocator.destroy(frame); |
| | 125 | frame.* = async command.exec(allocator, args[2..]); |
| | 126 | return await frame; |
| 124 | } | 127 | } |
| 125 | } | 128 | } |
| 126 | | 129 | |
| ... | @@ -852,10 +855,12 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { | ... | @@ -852,10 +855,12 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { |
| 852 | .exec = cmdInternalBuildInfo, | 855 | .exec = cmdInternalBuildInfo, |
| 853 | }}; | 856 | }}; |
| 854 | | 857 | |
| 855 | for (sub_commands) |sub_command| { | 858 | inline for (sub_commands) |sub_command| { |
| 856 | if (mem.eql(u8, sub_command.name, args[0])) { | 859 | if (mem.eql(u8, sub_command.name, args[0])) { |
| 857 | try sub_command.exec(allocator, args[1..]); | 860 | var frame = try allocator.create(@Frame(sub_command.exec)); |
| 858 | return; | 861 | defer allocator.destroy(frame); |
| | 862 | frame.* = async sub_command.exec(allocator, args[1..]); |
| | 863 | return await frame; |
| 859 | } | 864 | } |
| 860 | } | 865 | } |
| 861 | | 866 | |