add missing args

This commit is contained in:
Motiejus Jakštys 2022-07-06 12:35:17 +03:00
parent 6c6d9d9c2c
commit f2570529d7
3 changed files with 13 additions and 9 deletions

View File

@ -81,11 +81,14 @@ pub fn init(
} }
}; };
// TODO: replace with MultiArrayList sort when
// https://github.com/ziglang/zig/issues/11117 is done. As of writing it
// was quite a bit slower.
{ {
var name_idx = try baseAllocator.alloc(NameIdx, usersConst.len); var name_idx = try baseAllocator.alloc(NameIdx, usersConst.len);
defer baseAllocator.free(name_idx); defer baseAllocator.free(name_idx);
for (usersConst) |user, i| for (usersConst) |user, i| name_idx[i] =
name_idx[i] = NameIdx{ .name = user.name, .idx = i }; NameIdx{ .name = user.name, .idx = i };
sort.sort(NameIdx, name_idx, {}, Compare.name); sort.sort(NameIdx, name_idx, {}, Compare.name);
try users.ensureTotalCapacity(allocator, usersConst.len); try users.ensureTotalCapacity(allocator, usersConst.len);

View File

@ -21,7 +21,7 @@ const usage =
\\usage: turbo-analyze [options] [db.turbo] \\usage: turbo-analyze [options] [db.turbo]
\\ \\
\\ -h Print this help message and exit \\ -h Print this help message and exit
\\ [db.turbo] Path to the turbonss database file (default: ./db.turbo) \\ [db.turbo] Path to the turbonss database file (default: db.turbo)
\\ \\
; ;
@ -68,7 +68,7 @@ fn execute(
} }
const db_file = switch (myflags.args.len) { const db_file = switch (myflags.args.len) {
0 => "./db.turbo", 0 => "db.turbo",
1 => mem.span(myflags.args[0]), 1 => mem.span(myflags.args[0]),
else => { else => {
stderr.print("ERROR: too many arguments\n", .{}) catch {}; stderr.print("ERROR: too many arguments\n", .{}) catch {};

View File

@ -18,8 +18,9 @@ const usage =
\\usage: turbo-unix2db [options] \\usage: turbo-unix2db [options]
\\ \\
\\ -h Print this help message and exit \\ -h Print this help message and exit
\\ --passwd Path to passwd file (default: ./passwd) \\ --passwd Path to passwd file (default: passwd)
\\ --group Path to group file (default: ./group) \\ --group Path to group file (default: group)
\\ --output Path to output file (default: db.turbo)
\\ \\
; ;
@ -62,9 +63,9 @@ fn execute(
return 1; return 1;
} }
const passwd_fname = result.argFlag("--passwd") orelse "./passwd"; const passwd_fname = result.argFlag("--passwd") orelse "passwd";
const group_fname = result.argFlag("--group") orelse "./group"; const group_fname = result.argFlag("--group") orelse "group";
const out_fname = result.argFlag("--output") orelse "./db.turbo"; const out_fname = result.argFlag("--output") orelse "db.turbo";
// to catch an error set file.OpenError, wait for // to catch an error set file.OpenError, wait for
// https://github.com/ziglang/zig/issues/2473 // https://github.com/ziglang/zig/issues/2473