| ... | @@ -14,7 +14,7 @@ const PromptRet = struct { | ... | @@ -14,7 +14,7 @@ const PromptRet = struct { |
| 14 | value: []const u8, | 14 | value: []const u8, |
| 15 | }; | 15 | }; |
| 16 | | 16 | |
| 17 | fn doprompt(out: anytype, in: anytype, alloc: *std.mem.Allocator, default: ?[]const u8) !PromptRet { | 17 | fn doprompt(out: anytype, in: anytype, alloc: std.mem.Allocator, default: ?[]const u8) !PromptRet { |
| 18 | var n: usize = 1; | 18 | var n: usize = 1; |
| 19 | var value: []const u8 = undefined; | 19 | var value: []const u8 = undefined; |
| 20 | while (true) : (n += 1) { | 20 | while (true) : (n += 1) { |
| ... | @@ -41,7 +41,7 @@ fn clean(out: anytype, n: usize) !void { | ... | @@ -41,7 +41,7 @@ fn clean(out: anytype, n: usize) !void { |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | | 43 | |
| 44 | pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *std.mem.Allocator, comptime options: type, default: ?options) !options { | 44 | pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: std.mem.Allocator, comptime options: type, default: ?options) !options { |
| 45 | comptime std.debug.assert(@typeInfo(options) == .Enum); | 45 | comptime std.debug.assert(@typeInfo(options) == .Enum); |
| 46 | const def: ?[]const u8 = if (default) |d| @tagName(d) else null; | 46 | const def: ?[]const u8 = if (default) |d| @tagName(d) else null; |
| 47 | | 47 | |
| ... | @@ -77,7 +77,7 @@ pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *s | ... | @@ -77,7 +77,7 @@ pub fn forEnum(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *s |
| 77 | return value; | 77 | return value; |
| 78 | } | 78 | } |
| 79 | | 79 | |
| 80 | pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *std.mem.Allocator, default: ?[]const u8) ![]const u8 { | 80 | pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc: std.mem.Allocator, default: ?[]const u8) ![]const u8 { |
| 81 | try out.print(comptime ansi.color.Fg(.Green, "? "), .{}); | 81 | try out.print(comptime ansi.color.Fg(.Green, "? "), .{}); |
| 82 | try out.print(comptime ansi.color.Bold(prompt ++ " "), .{}); | 82 | try out.print(comptime ansi.color.Bold(prompt ++ " "), .{}); |
| 83 | | 83 | |
| ... | @@ -92,7 +92,7 @@ pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc: | ... | @@ -92,7 +92,7 @@ pub fn forString(out: anytype, in: anytype, comptime prompt: []const u8, alloc: |
| 92 | return try answer(out, prompt, []const u8, "{s}", p.value); | 92 | return try answer(out, prompt, []const u8, "{s}", p.value); |
| 93 | } | 93 | } |
| 94 | | 94 | |
| 95 | pub fn forConfirm(out: anytype, in: anytype, comptime prompt: []const u8, alloc: *std.mem.Allocator) !bool { | 95 | pub fn forConfirm(out: anytype, in: anytype, comptime prompt: []const u8, alloc: std.mem.Allocator) !bool { |
| 96 | return (try forEnum(out, in, prompt, alloc, enum { y, n }, .y)) == .y; | 96 | return (try forEnum(out, in, prompt, alloc, enum { y, n }, .y)) == .y; |
| 97 | } | 97 | } |
| 98 | | 98 | |