| 1 | const std = @import("std"); |
| 2 | const inquirer = @import("inquirer"); |
| 3 | const nfs = @import("nfs"); |
| 4 | |
| 5 | // Comparison adaptation of https://github.com/SBoudrias/Inquirer.js/blob/master/packages/inquirer/examples/pizza.js |
| 6 | |
| 7 | pub fn main() !void { |
| 8 | std.log.info("All your codebase are belong to us.", .{}); |
| 9 | |
| 10 | var gpa = std.heap.DebugAllocator(.{}){}; |
| 11 | const alloc = gpa.allocator(); |
| 12 | |
| 13 | const in = nfs.stdin(); |
| 14 | const out = nfs.stdout(); |
| 15 | |
| 16 | _ = try inquirer.forConfirm(out, in, "Is this for delivery?", alloc); |
| 17 | |
| 18 | _ = try inquirer.forString(out, in, "What's your phone number?", alloc, null); |
| 19 | |
| 20 | _ = try inquirer.forEnum(out, in, "What size do you need?", alloc, enum { Small, Medium, Large }, null); |
| 21 | |
| 22 | // _ = try inquirer.forNumber(out,in,"How many do you need?", alloc, u32, 1); |
| 23 | // TODO forNumber is causing a compiler crash |
| 24 | |
| 25 | // TODO toppings for string list |
| 26 | |
| 27 | _ = try inquirer.forEnum(out, in, "You also get a free 2L:", alloc, enum { Pepsi, @"7up", Coke }, null); |
| 28 | |
| 29 | const comment = try inquirer.forString(out, in, "Any comments on your purchase experience?", alloc, "Nope, all good!"); |
| 30 | |
| 31 | if (!std.mem.eql(u8, comment, "Nope, all good!")) { |
| 32 | _ = try inquirer.forEnum(out, in, "For leaving a comment, you get a freebie:", alloc, enum { Cake, Fries }, null); |
| 33 | } |
| 34 | } |