add help to demo program

This commit is contained in:
Emil Lerch 2023-08-29 07:26:11 -07:00
parent 591f4c43e0
commit 58949127d6
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -63,7 +63,25 @@ pub fn main() anyerror!void {
defer tests.deinit();
var args = try std.process.argsWithAllocator(allocator);
defer args.deinit();
const stdout_raw = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_raw);
defer bw.flush() catch unreachable;
const stdout = bw.writer();
var arg0: ?[]const u8 = null;
while (args.next()) |arg| {
if (arg0 == null) arg0 = arg;
if (std.mem.eql(u8, "-h", arg) or std.mem.eql(u8, "--help", arg)) {
try stdout.print(
\\usage: {?s} [-h|--help] [-v][-v][-v] [test_name...]
\\
\\Where tests are one of the following:
\\
, .{arg0});
inline for (std.meta.fields(Tests)) |enumfield| {
try stdout.print("* {s}\n", .{enumfield.name});
}
return;
}
if (std.mem.eql(u8, "-v", arg)) {
verbose += 1;
continue;