cli/list-keybinds: prevent ios, tvos, and watchos from pretty printing

These oses don't supply a tty layer, which prevents us from using the
libvaxis tty. Eventually we can add in using stdout as a writer. For
now, we just don't pretty print there.
This commit is contained in:
Tim Culverhouse
2024-08-06 12:40:36 -05:00
parent 59e226154c
commit 1e91efbbe5

View File

@ -57,8 +57,13 @@ pub fn run(alloc: Allocator) !u8 {
defer config.deinit();
const stdout = std.io.getStdOut();
const can_pretty_print = switch (builtin.os.tag) {
.ios, .tvos, .watchos => false,
else => true,
};
// Despite being under the posix namespace, this also works on Windows as of zig 0.13.0
if (std.posix.isatty(stdout.handle) and !opts.plain) {
if (can_pretty_print and !opts.plain and std.posix.isatty(stdout.handle)) {
return prettyPrint(alloc, config.keybind);
} else {
try config.keybind.formatEntryDocs(