~gpanders/wk

2b92540a79bcc7513853514ee61bc4126e5e8f04 — Greg Anders 3 months ago 20be22b
Print new Zettel name when stdout is not a tty
1 files changed, 7 insertions(+), 0 deletions(-)

M src/cmd/new.zig
M src/cmd/new.zig => src/cmd/new.zig +7 -0
@@ 1,6 1,8 @@
const std = @import("std");
const io = std.io;
const fmt = std.fmt;
const mem = std.mem;
const stdout = std.io.getStdOut().outStream();

const Command = @import("../cmd.zig").Command;
const Zettel = @import("../zettel.zig").Zettel;


@@ 21,6 23,11 @@ pub fn run(allocator: *mem.Allocator, args: ?[]const []const u8) Command.Error!v
        const title = args.?[0];
        var new_zettel = try Zettel.new(allocator, title);

        if (!io.getStdOut().isTty()) {
            stdout.print("{}\n", .{new_zettel.fname}) catch {};
            return;
        }

        try openZettels(allocator, &[_]Zettel{new_zettel});

        new_zettel.contents = try new_zettel.read();