| ... | @@ -1,9 +1,15 @@ | ... | @@ -1,9 +1,15 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| | 2 | const builtin = @import("builtin"); |
| 2 | const string = [:0]const u8; | 3 | const string = [:0]const u8; |
| 3 | const List = std.ArrayList(string); | 4 | const List = std.ArrayList(string); |
| 4 | const extras = @import("extras"); | 5 | const extras = @import("extras"); |
| 5 | const linux = @import("sys-linux"); | 6 | const linux = @import("sys-linux"); |
| 6 | | 7 | |
| | 8 | const sys = switch (builtin.target.os.tag) { |
| | 9 | .linux => linux, |
| | 10 | else => unreachable, // TODO: |
| | 11 | }; |
| | 12 | |
| 7 | var singles: std.ArrayHashMap(string, string, std.array_hash_map.StringContext, true) = undefined; | 13 | var singles: std.ArrayHashMap(string, string, std.array_hash_map.StringContext, true) = undefined; |
| 8 | var multis: std.ArrayHashMap(string, List, std.array_hash_map.StringContext, true) = undefined; | 14 | var multis: std.ArrayHashMap(string, List, std.array_hash_map.StringContext, true) = undefined; |
| 9 | | 15 | |
| ... | @@ -68,7 +74,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator { | ... | @@ -68,7 +74,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator { |
| 68 | } | 74 | } |
| 69 | } | 75 | } |
| 70 | std.log.err("Unrecognized argument: {s}{s}", .{ dash, name }); | 76 | std.log.err("Unrecognized argument: {s}{s}", .{ dash, name }); |
| 71 | linux.exit(1); | 77 | sys.exit(1); |
| 72 | } | 78 | } |
| 73 | return argiter; | 79 | return argiter; |
| 74 | } | 80 | } |
| ... | @@ -77,7 +83,7 @@ pub fn parseEnv() !void { | ... | @@ -77,7 +83,7 @@ pub fn parseEnv() !void { |
| 77 | const alloc = singles.allocator; | 83 | const alloc = singles.allocator; |
| 78 | | 84 | |
| 79 | for (singles.keys(), singles.values()) |k, *v| { | 85 | for (singles.keys(), singles.values()) |k, *v| { |
| 80 | if (linux.getenv(k)) |value| { | 86 | if (sys.getenv(k)) |value| { |
| 81 | v.* = value; | 87 | v.* = value; |
| 82 | } | 88 | } |
| 83 | } | 89 | } |
| ... | @@ -86,7 +92,7 @@ pub fn parseEnv() !void { | ... | @@ -86,7 +92,7 @@ pub fn parseEnv() !void { |
| 86 | while (true) : (n += 1) { | 92 | while (true) : (n += 1) { |
| 87 | const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ k, n }); | 93 | const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ k, n }); |
| 88 | defer alloc.free(w); | 94 | defer alloc.free(w); |
| 89 | if (linux.getenv(w)) |value| { | 95 | if (sys.getenv(w)) |value| { |
| 90 | try v.append(value); | 96 | try v.append(value); |
| 91 | continue; | 97 | continue; |
| 92 | } | 98 | } |