blob: c45cbed092cbcabdede50e78007eb9c10f6d837a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const std = @import("std");
const dump = @import("dump.zig");
const adler32 = std.hash.Adler32;
fn help(args: [][]u8) u8 {
std.debug.warn(
\\Usage: {} [subcommand] [options]
\\
\\Resource Compiler for C++
\\
\\Subcommands:
\\ dump [options] inputs hexdump the input files
\\
\\For a full list of subcommand options, use [subcommand] --help
\\
, .{args[0]});
return if (args.len < 2) 255 else 0;
}
pub fn main() anyerror!u8 {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const args = try std.process.argsAlloc(&arena.allocator);
if (args.len < 2) {
return help(args);
}
return switch (adler32.hash(args[1])) {
adler32.hash("dump") => dump.cmd(args),
adler32.hash("-h"), adler32.hash("--help") => help(args),
else => help(args),
};
}
|