| 1 | # zig-inquirer |
| 2 | |
| 3 |  |
| 4 | [](https://github.com/nektro/zig-inquirer/blob/master/LICENSE) |
| 5 | [](https://github.com/sponsors/nektro) |
| 6 | [](https://ziglang.org/) |
| 7 | [](https://github.com/nektro/zigmod) |
| 8 | |
| 9 | A collection of utilities for prompting information from the user on the CLI |
| 10 | |
| 11 | Adapted from https://github.com/SBoudrias/Inquirer.js |
| 12 | |
| 13 | ## Run example |
| 14 | |
| 15 | ``` |
| 16 | zig build run |
| 17 | ``` |
| 18 | |
| 19 | ## Screenshots |
| 20 | |
| 21 |  |
| 22 | |
| 23 | ## Usage |
| 24 | |
| 25 | - `pub fn answer(writer, reader, comptime prompt: []const u8, value: []const u8) []const u8` |
| 26 | - Prints just the done string. |
| 27 | - `pub fn forEnum(writer, reader, comptime prompt: []const u8, alloc: *std.mem.Allocator, comptime options: enum, default: ?options) !options` |
| 28 | - Accepts an enum and prompts the user to pick on of the fields. |
| 29 | - `pub fn forString(writer, reader, comptime prompt: []const u8, alloc: *std.mem.Allocator, default: ?[]const u8) ![]const u8` |
| 30 | - Base function, asks prompt and returns non-empty answer. |
| 31 | - `pub fn forConfirm(writer, reader, comptime prompt: []const u8, alloc: *std.mem.Allocator) !bool` |
| 32 | - Calls `forEnum` with `y/n` |
| 33 | |
| 34 | ## TODO |
| 35 | |
| 36 | - number (current implementation causes compiler crash) |
| 37 | - list with strings |
| 38 | - string password |
| 39 | - long list with autocomplete |
| 40 | - date |
| 41 | - time |