A pretty printer for zig
zig
at main 59 lines 1.1 kB view raw view rendered
1# pretty 2 3A compile-time pretty printer for Zig with colored terminal output. 4 5## Installation 6 7Run: 8```sh 9zig fetch --save git+https://git.sr.ht/~altagos/pretty#main 10``` 11Or manually add to `build.zig.zon`: 12```zig 13.dependencies = .{ 14 .pretty = .{ 15 .url = "git+https://git.sr.ht/~altagos/pretty#main", 16 .hash = "<HASH>", 17 }, 18} 19``` 20 21In `build.zig`: 22```zig 23const pretty = b.dependency("pretty", .{ .target = target, .optimize = optimize }); 24exe.root_module.addImport("pretty", pretty.module("pretty")); 25``` 26 27## Usage 28 29For a detailed example, see [example/main](./example/main.zig) 30 31```zig 32const pretty = @import("pretty").pretty; 33 34std.debug.print("{f}\n", .{pretty(my_value)}); 35``` 36 37### With Options 38 39```zig 40const prettyO = @import("pretty").prettyO; 41 42std.debug.print("{f}\n", .{prettyO(my_value, .{ 43 .struct_inline = true, 44 .array_inline = true, 45})}); 46``` 47 48### Global Defaults 49 50```zig 51pub const pretty_options = @import("pretty").Options{ 52 .skip_root_type_name = true, 53 .theme = .{ .indent_width = 4 }, 54}; 55``` 56 57## License 58 59[MIT License](./LICENSE)