| author | |
| committer | |
| log | 1cbf74a6e96c0591c8979ef0eabf714bdaa6eefd |
| tree | d4f157cc731fcd5442f8deead6d8ff3227e295a0 |
| parent | 94d2ad2f7b187287101947911442d9126927c904 |
9 files changed, 18 insertions(+), 19 deletions(-)
src/cmd/aq.zig+1-1| ... | ... | @@ -39,7 +39,7 @@ pub fn execute(args: [][]u8) !void { |
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | u.assert(false, "unknown command \"{s}\" for \"zigmod aq\"", .{args[0]}); | |
| 42 | u.fail("unknown command \"{s}\" for \"zigmod aq\"", .{args[0]}); | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | pub fn server_fetch(url: []const u8) !json.Value { |
src/cmd/fetch.zig+1-1| ... | ... | @@ -322,7 +322,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), d |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | if (notdone.items.len == len) { |
| 325 | u.assert(false, "notdone still has {d} items", .{len}); | |
| 325 | u.fail("notdone still has {d} items", .{len}); | |
| 326 | 326 | } |
| 327 | 327 | len = notdone.items.len; |
| 328 | 328 | } |
src/cmd/init.zig+1-2| ... | ... | @@ -31,8 +31,7 @@ pub fn execute(args: [][]u8) !void { |
| 31 | 31 | |
| 32 | 32 | const name = try inquirer.forString(stdout, stdin, "package name:", gpa, u.detect_pkgname(u.try_index([]const u8, args, 0, ""), "") catch |err| switch (err) { |
| 33 | 33 | error.NoBuildZig => { |
| 34 | u.assert(false, "init requires a build.zig file", .{}); | |
| 35 | unreachable; | |
| 34 | u.fail("init requires a build.zig file", .{}); | |
| 36 | 35 | }, |
| 37 | 36 | else => return err, |
| 38 | 37 | }); |
src/cmd/zpm.zig+1-1| ... | ... | @@ -50,7 +50,7 @@ pub fn execute(args: [][]u8) !void { |
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | u.assert(false, "unknown command \"{s}\" for \"zigmod zpm\"", .{args[0]}); | |
| 53 | u.fail("unknown command \"{s}\" for \"zigmod zpm\"", .{args[0]}); | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | pub fn server_fetch(url: []const u8) !json.Value { |
src/cmd/zpm/add.zig+1-2| ... | ... | @@ -28,8 +28,7 @@ pub fn execute(args: [][]u8) !void { |
| 28 | 28 | break :blk pkg; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | u.assert(false, "no package with name '{s}' found", .{args[0]}); | |
| 32 | unreachable; | |
| 31 | u.fail("no package with name '{s}' found", .{args[0]}); | |
| 33 | 32 | }; |
| 34 | 33 | |
| 35 | 34 | u.assert(found.root_file != null, "package must have an entry point to be able to be added to your dependencies", .{}); |
src/common.zig+5-7| ... | ... | @@ -127,8 +127,7 @@ pub fn get_modpath(cachepath: []const u8, d: u.Dep, options: *CollectOptions) ![ |
| 127 | 127 | error.IterEmpty => unreachable, |
| 128 | 128 | error.NoMemberFound => { |
| 129 | 129 | const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; |
| 130 | u.assert(false, "fetch: git: version type '{s}' is invalid.", .{vtype}); | |
| 131 | unreachable; | |
| 130 | u.fail("fetch: git: version type '{s}' is invalid.", .{vtype}); | |
| 132 | 131 | }, |
| 133 | 132 | }; |
| 134 | 133 | if (try u.does_folder_exist(pv)) { |
| ... | ... | @@ -141,7 +140,7 @@ pub fn get_modpath(cachepath: []const u8, d: u.Dep, options: *CollectOptions) ![ |
| 141 | 140 | } |
| 142 | 141 | try d.type.pull(d.path, pv); |
| 143 | 142 | if ((try u.run_cmd(pv, &.{ "git", "checkout", vers.string })) > 0) { |
| 144 | u.assert(false, "fetch: git: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); | |
| 143 | u.fail("fetch: git: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); | |
| 145 | 144 | } |
| 146 | 145 | if (builtin.os.tag != .windows and vers.id != .branch) { |
| 147 | 146 | const pvd = try std.fs.cwd().openDir(pv, .{}); |
| ... | ... | @@ -184,7 +183,7 @@ pub fn get_modpath(cachepath: []const u8, d: u.Dep, options: *CollectOptions) ![ |
| 184 | 183 | return pv; |
| 185 | 184 | } |
| 186 | 185 | try std.fs.cwd().deleteTree(pv); |
| 187 | u.assert(false, "{s} does not match hash {s}", .{ d.path, d.version }); | |
| 186 | u.fail("{s} does not match hash {s}", .{ d.path, d.version }); | |
| 188 | 187 | return p; |
| 189 | 188 | } |
| 190 | 189 | if (try u.does_folder_exist(p)) { |
| ... | ... | @@ -253,8 +252,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, options: *CollectOp |
| 253 | 252 | if (mod_from.is_for_this()) return mod_from; |
| 254 | 253 | return null; |
| 255 | 254 | } |
| 256 | u.assert(false, "no zig.mod found and no override props defined. unable to use add this dependency!", .{}); | |
| 257 | unreachable; | |
| 255 | u.fail("no zig.mod found and no override props defined. unable to use add this dependency!", .{}); | |
| 258 | 256 | }, |
| 259 | 257 | else => e, |
| 260 | 258 | }; |
| ... | ... | @@ -390,7 +388,7 @@ pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4][]const u8 { |
| 390 | 388 | }); |
| 391 | 389 | }, |
| 392 | 390 | else => { |
| 393 | u.assert(false, "invalid zigmod.lock version: {d}", .{v}); | |
| 391 | u.fail("invalid zigmod.lock version: {d}", .{v}); | |
| 394 | 392 | }, |
| 395 | 393 | } |
| 396 | 394 | } |
src/main.zig+1-2| ... | ... | @@ -63,8 +63,7 @@ pub fn main() !void { |
| 63 | 63 | const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) { |
| 64 | 64 | else => return e, |
| 65 | 65 | error.FileNotFound => { |
| 66 | u.assert(false, "unknown command \"{s}\" for \"zigmod\"", .{args[0]}); | |
| 67 | unreachable; | |
| 66 | u.fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]}); | |
| 68 | 67 | }, |
| 69 | 68 | }; |
| 70 | 69 | try std.io.getStdOut().writeAll(result.stdout); |
src/util/funcs.zig+6-2| ... | ... | @@ -25,6 +25,11 @@ pub fn assert(ok: bool, comptime fmt: []const u8, args: anytype) void { |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | pub fn fail(comptime fmt: []const u8, args: anytype) noreturn { | |
| 29 | assert(false, fmt, args); | |
| 30 | unreachable; | |
| 31 | } | |
| 32 | ||
| 28 | 33 | pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T { |
| 29 | 34 | if (array.len <= n) { |
| 30 | 35 | return def; |
| ... | ... | @@ -160,8 +165,7 @@ pub fn file_list(dpath: []const u8, list: *std.ArrayList([]const u8)) !void { |
| 160 | 165 | pub fn run_cmd_raw(dir: ?[]const u8, args: []const []const u8) !std.ChildProcess.ExecResult { |
| 161 | 166 | return std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) { |
| 162 | 167 | error.FileNotFound => { |
| 163 | u.assert(false, "\"{s}\" command not found", .{args[0]}); | |
| 164 | unreachable; | |
| 168 | u.fail("\"{s}\" command not found", .{args[0]}); | |
| 165 | 169 | }, |
| 166 | 170 | else => return e, |
| 167 | 171 | }; |
src/util/modfile.zig+1-1| ... | ... | @@ -48,7 +48,7 @@ pub const ModFile = struct { |
| 48 | 48 | const main = mapping.get_string("main"); |
| 49 | 49 | |
| 50 | 50 | if (std.mem.indexOf(u8, name, "/")) |_| { |
| 51 | u.assert(false, "name may not contain any '/'", .{}); | |
| 51 | u.fail("name may not contain any '/'", .{}); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return Self{ |