76 lines
1.6 KiB
Zig
76 lines
1.6 KiB
Zig
|
const std = @import("std");
|
||
|
|
||
|
const noclip = @import("noclip");
|
||
|
|
||
|
const config = @import("./config.zig");
|
||
|
|
||
|
const scribe_cmd = cmd: {
|
||
|
var builder = noclip.CommandBuilder(*const std.mem.Allocator){
|
||
|
.description =
|
||
|
\\consume lore files and produce rendered output
|
||
|
\\
|
||
|
\\
|
||
|
,
|
||
|
};
|
||
|
|
||
|
break :cmd builder;
|
||
|
};
|
||
|
|
||
|
pub fn scribe(alloc: *const std.mem.Allocator, _: scribe_cmd.Output()) !void {
|
||
|
var parser = config.Parser{ .allocator = alloc.* };
|
||
|
|
||
|
_ = try parser.dumpBufLines(
|
||
|
\\# this is a comment
|
||
|
\\key: value
|
||
|
\\key2:
|
||
|
\\ - electric
|
||
|
\\ - boogaloo
|
||
|
\\#comment
|
||
|
\\
|
||
|
\\
|
||
|
\\
|
||
|
\\#commentary
|
||
|
\\
|
||
|
\\keyzo: > fake string
|
||
|
\\
|
||
|
\\beezo:
|
||
|
\\ > this string
|
||
|
\\ # comment
|
||
|
\\ | goes on
|
||
|
\\
|
||
|
\\ > and on
|
||
|
\\
|
||
|
\\qux:
|
||
|
\\ {my: flow, is: unstoppable}
|
||
|
\\qux: {my: flow, is: unstoppable}
|
||
|
\\qux: [my, flow, is, unstoppable]
|
||
|
\\qux: > {my: flow, is: unstoppable}
|
||
|
\\quux:
|
||
|
\\ [one, two, three]
|
||
|
\\
|
||
|
\\
|
||
|
\\foo:
|
||
|
\\ -
|
||
|
\\ bar:
|
||
|
\\ -
|
||
|
\\
|
||
|
\\ bazinga
|
||
|
\\baz: 1
|
||
|
\\
|
||
|
);
|
||
|
}
|
||
|
|
||
|
pub fn run(alloc: std.mem.Allocator) !void {
|
||
|
const base = try noclip.commandGroup(alloc, .{
|
||
|
.description =
|
||
|
\\produce and manipulate collections of lore
|
||
|
\\
|
||
|
,
|
||
|
});
|
||
|
defer base.deinitTree();
|
||
|
|
||
|
try base.addSubcommand("scribe", try scribe_cmd.createInterface(alloc, scribe, &alloc));
|
||
|
|
||
|
try base.execute();
|
||
|
}
|