diff options
author | Manlio Perillo <manlio.perillo@gmail.com> | 2023-05-08 18:11:29 +0200 |
---|---|---|
committer | Manlio Perillo <manlio.perillo@gmail.com> | 2023-05-09 11:11:03 +0200 |
commit | ea4144a41662fe42ebf2f8f5b089a6defbfaed79 (patch) | |
tree | 182a281ee5183cb45d997fd84b0ba473822417b0 /build.zig | |
parent | 9de89f6d604753a97afbf739f575fcd21cbd85a3 (diff) |
build: add the dumpArgs function
Use it in Zigling.compile, in order to reduce code duplication.
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -388,37 +388,32 @@ const ZiglingStep = struct { print("{s}{s}: Unable to spawn the following command: file not found{s}\n", .{ red_text, self.exercise.main_file, reset_text, }); - for (argv) |v| print("{s} ", .{v}); - print("\n", .{}); + dumpArgs(argv); }, error.ExitCodeFailure => { print("{s}{s}: The following command exited with error code {}:{s}\n", .{ red_text, self.exercise.main_file, code, reset_text, }); - for (argv) |v| print("{s} ", .{v}); - print("\n", .{}); + dumpArgs(argv); }, error.ProcessTerminated => { print("{s}{s}: The following command terminated unexpectedly:{s}\n", .{ red_text, self.exercise.main_file, reset_text, }); - for (argv) |v| print("{s} ", .{v}); - print("\n", .{}); + dumpArgs(argv); }, error.ZigIPCError => { // Commenting this out for now. It always shows up when compilation fails. //print("{s}{s}: The following command failed to communicate the compilation result:{s}\n", .{ // red_text, self.exercise.main_file, reset_text, //}); - //for (argv) |v| print("{s} ", .{v}); - //print("\n", .{}); + //dumpArgs(argv); }, else => { print("{s}{s}: Unexpected error: {s}{s}\n", .{ red_text, self.exercise.main_file, @errorName(err), reset_text, }); - for (argv) |v| print("{s} ", .{v}); - print("\n", .{}); + dumpArgs(argv); }, } @@ -568,6 +563,11 @@ const ZiglingStep = struct { } }; +fn dumpArgs(args: []const []const u8) void { + for (args) |arg| print("{s} ", .{arg}); + print("\n", .{}); +} + /// Clears the entire line and move the cursor to column zero. /// Used for clearing the compiler and build_runner progress messages. fn resetLine() void { |