51 lines
1.4 KiB
Zig
51 lines
1.4 KiB
Zig
// Reads in a .tad file and generates an api
|
|
|
|
pub const std_options: std.Options = .{
|
|
.log_level = .info, // Options: .err, .warn, .info, .debug
|
|
.log_scope_levels = &[_]std.log.ScopeLevel{
|
|
.{ .scope = .generateApi, .level = .debug },
|
|
} ++ tad.logScopeLevels,
|
|
};
|
|
|
|
const helpText =
|
|
\\generate-api
|
|
\\
|
|
\\takes an input file and outputs source and output zig files
|
|
\\
|
|
;
|
|
const AP = SimpleArgParse("generate-api", helpText);
|
|
|
|
pub fn main(init: std.process.Init) !void {
|
|
AP.initArgsMap(init.arena.allocator());
|
|
|
|
const argv = init.minimal.args.vector;
|
|
|
|
for (argv) |a| {
|
|
if (AP.cliArgParse(a, "help", "shows the help dialogue")) |arg| {
|
|
_ = arg;
|
|
try AP.printHelp(init.io);
|
|
}
|
|
if (AP.cliArgParse(a, "input-file", "input .tad file to parse")) |arg| {
|
|
log.info("parsing input file: {s}", .{arg});
|
|
|
|
try tad.compileAll(.{
|
|
.io = init.io,
|
|
.allocator = init.arena.allocator(),
|
|
.path = arg,
|
|
});
|
|
}
|
|
}
|
|
|
|
AP.writeArgsMap(init.io) catch unreachable;
|
|
if (!AP.parsedOne) {
|
|
try AP.printHelp(init.io);
|
|
}
|
|
log.info("done :)", .{});
|
|
}
|
|
|
|
const log = std.log.scoped(.generateApi);
|
|
const std = @import("std");
|
|
const mem = std.mem;
|
|
const SimpleArgParse = @import("common/args.zig").SimpleArgParse;
|
|
const tad = @import("tad/tad.zig");
|