| ... | ... | @@ -28,9 +28,9 @@ pub fn fatal(comptime format: []const u8, args: anytype) noreturn { |
| 28 | 28 | pub const max_src_size = 2 * 1024 * 1024 * 1024; // 2 GiB |
| 29 | 29 | |
| 30 | 30 | pub const Color = enum { |
| 31 | | Auto, |
| 32 | | Off, |
| 33 | | On, |
| 31 | auto, |
| 32 | off, |
| 33 | on, |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | const usage = |
| ... | ... | @@ -380,7 +380,7 @@ fn buildOutputType( |
| 380 | 380 | run, |
| 381 | 381 | }, |
| 382 | 382 | ) !void { |
| 383 | | var color: Color = .Auto; |
| 383 | var color: Color = .auto; |
| 384 | 384 | var optimize_mode: std.builtin.Mode = .Debug; |
| 385 | 385 | var provided_name: ?[]const u8 = null; |
| 386 | 386 | var link_mode: ?std.builtin.LinkMode = null; |
| ... | ... | @@ -585,15 +585,9 @@ fn buildOutputType( |
| 585 | 585 | } |
| 586 | 586 | i += 1; |
| 587 | 587 | const next_arg = args[i]; |
| 588 | | if (mem.eql(u8, next_arg, "auto")) { |
| 589 | | color = .Auto; |
| 590 | | } else if (mem.eql(u8, next_arg, "on")) { |
| 591 | | color = .On; |
| 592 | | } else if (mem.eql(u8, next_arg, "off")) { |
| 593 | | color = .Off; |
| 594 | | } else { |
| 588 | color = std.meta.stringToEnum(Color, next_arg) orelse { |
| 595 | 589 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); |
| 596 | | } |
| 590 | }; |
| 597 | 591 | } else if (mem.eql(u8, arg, "--subsystem")) { |
| 598 | 592 | if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); |
| 599 | 593 | i += 1; |
| ... | ... | @@ -2374,7 +2368,7 @@ const Fmt = struct { |
| 2374 | 2368 | |
| 2375 | 2369 | pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2376 | 2370 | const stderr_file = io.getStdErr(); |
| 2377 | | var color: Color = .Auto; |
| 2371 | var color: Color = .auto; |
| 2378 | 2372 | var stdin_flag: bool = false; |
| 2379 | 2373 | var check_flag: bool = false; |
| 2380 | 2374 | var input_files = ArrayList([]const u8).init(gpa); |
| ... | ... | @@ -2394,15 +2388,9 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 2394 | 2388 | } |
| 2395 | 2389 | i += 1; |
| 2396 | 2390 | const next_arg = args[i]; |
| 2397 | | if (mem.eql(u8, next_arg, "auto")) { |
| 2398 | | color = .Auto; |
| 2399 | | } else if (mem.eql(u8, next_arg, "on")) { |
| 2400 | | color = .On; |
| 2401 | | } else if (mem.eql(u8, next_arg, "off")) { |
| 2402 | | color = .Off; |
| 2403 | | } else { |
| 2391 | color = std.meta.stringToEnum(Color, next_arg) orelse { |
| 2404 | 2392 | fatal("expected [auto|on|off] after --color, found '{}'", .{next_arg}); |
| 2405 | | } |
| 2393 | }; |
| 2406 | 2394 | } else if (mem.eql(u8, arg, "--stdin")) { |
| 2407 | 2395 | stdin_flag = true; |
| 2408 | 2396 | } else if (mem.eql(u8, arg, "--check")) { |
| ... | ... | @@ -2626,9 +2614,9 @@ fn printErrMsgToFile( |
| 2626 | 2614 | color: Color, |
| 2627 | 2615 | ) !void { |
| 2628 | 2616 | const color_on = switch (color) { |
| 2629 | | .Auto => file.isTty(), |
| 2630 | | .On => true, |
| 2631 | | .Off => false, |
| 2617 | .auto => file.isTty(), |
| 2618 | .on => true, |
| 2619 | .off => false, |
| 2632 | 2620 | }; |
| 2633 | 2621 | const lok_token = parse_error.loc(); |
| 2634 | 2622 | const span_first = lok_token; |