Skip to content
zit Artifact [b283beb15f]
Login

Artifact [b283beb15f]

Artifact b283beb15f3455e80d558ffefa93b9091e17458fdfdce6d3538971e6b88a3357:


//! zit — command-line entry point.
//!
//! The heavy lifting lives in the `zit` library module (src/root.zig and the
//! per-RFC modules it re-exports). This file is only the CLI surface.

const std = @import("std");
const Io = std.Io;
const zit = @import("zit");

pub fn main(init: std.process.Init) !void {
    const arena = init.arena.allocator();
    const args = try init.minimal.args.toSlice(arena);

    var stdout_buffer: [1024]u8 = undefined;
    var stdout_writer: Io.File.Writer = .init(.stdout(), init.io, &stdout_buffer);
    const out = &stdout_writer.interface;

    const cmd = if (args.len >= 2) args[1] else "help";

    if (std.mem.eql(u8, cmd, "version")) {
        try out.writeAll("zit 0.0.0 (targets Fossil RFC rev " ++ zit.rfc_revision ++ ")\n");
    } else if (std.mem.eql(u8, cmd, "help") or std.mem.eql(u8, cmd, "-h") or std.mem.eql(u8, cmd, "--help")) {
        try out.writeAll(usage);
    } else {
        try out.writeAll("zit: unknown command '");
        try out.writeAll(cmd);
        try out.writeAll("'\n\n");
        try out.writeAll(usage);
        try out.flush();
        std.process.exit(2);
    }
    try out.flush();
}

const usage =
    \\zit — a Fossil version-control system in Zig
    \\
    \\usage: zit <command> [args]
    \\
    \\commands:
    \\  version    print the version
    \\  help       show this help
    \\
    \\This is a scaffold. Implementation follows the RFC layering in docs/rfcs/:
    \\  delta -> artifact -> repostate -> sync
    \\
;