"Jesse Phillips" <[email protected]> wrote in message news:[email protected]... > > I created a cmdln library to help with user interaction, which some seem > to like. > > https://github.com/he-the-great/JPDLibs/tree/cmdln >
Looks very nice. I have a similar (but probably more basic) thing, too (just one function: "prompt"): http://www.dsource.org/projects/semitwist/browser/trunk/src/semitwist/cmd/plain.d#L216 // -- Basic string prompt ------ string input1 = prompt("Type some stuff: "); // -- String prompt with validation ------ // (failureMsg is optional) string promptMsg = "Do you want 'coffee' or 'tea'? "; string failureMsg = "Please enter 'coffee' or 'tea', not '%s'"; bool accept(string input) { return ["coffee", "tea"].contains(tolower(input)); } // This will *not* return until the user enters a valid choice, // so we don't need to do any more validation. string input2 = prompt(promptMsg, &accept, failureMsg);
